triggered signal

This commit is contained in:
Marco Martin 2011-12-21 19:52:35 +01:00
parent f3edf32cb7
commit 1a4a4b8f45
2 changed files with 14 additions and 0 deletions

View File

@ -31,6 +31,8 @@ QMenuProxy::QMenuProxy (QObject *parent)
m_status(DialogStatus::Closed)
{
m_menu = new QMenu(0);
connect(m_menu, SIGNAL(triggered(QAction *)),
this, SLOT(itemTriggered(QAction *)));
}
QMenuProxy::~QMenuProxy()
@ -86,6 +88,14 @@ void QMenuProxy::addMenuItem(const QString &text)
m_items << item;
}
void QMenuProxy::itemTriggered(QAction *action)
{
QMenuItem *item = qobject_cast<QMenuItem *>(action);
if (item) {
emit triggered(item);
}
}
void QMenuProxy::showMenu(int x, int y)
{
m_menu->clear();

View File

@ -58,6 +58,10 @@ public:
Q_SIGNALS:
void statusChanged();
void visualParentChanged();
void triggered(QMenuItem*);
private Q_SLOTS:
void itemTriggered(QAction *item);
private:
QList<QMenuItem*> m_items;