[Qt-interest] Which Action?
Szalata, Zenon M.
zms at slac.stanford.edu
Tue Sep 27 06:42:07 CEST 2011
Thanks again,
I continued looking for an example that would show how to do this and found one in the book on QT:
"C++ GUI Programming with Qt 4, second Edition", by Jasmine Blanchette and Mark Summerfield.
Here is a snippet of how I implemented this and it works:
void MainWindow::_triggered(){
//------------------------------------------------------------------------------
QAction* action=qobject_cast<QAction*>(sender());
if(!action) return;
...
}
Where MainWIndow::_triggered() is a slot function connected with the triggered(bool) signal for all actions of interest.
Zen
From: qt-interest-bounces+zms=slac.stanford.edu at qt.nokia.com [mailto:qt-interest-bounces+zms=slac.stanford.edu at qt.nokia.com] On Behalf Of MARTIN Pierre
Sent: Monday, September 26, 2011 3:00 PM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Which Action?
In the actionTriggered() function I need to know which action triggered the call.
Is there a way to get that information in the actionTriggered() function?
Also, i suggest you look at the QMenu triggered(QAction*) signal, which sends a pointer to the QAction which has been triggered here:
http://doc.qt.nokia.com/latest/qmenu.html#signals
And i believe instead of connecting each individual action to a slot, you just connect the parent menu to a slot which will be called whatever action is triggered.
Pierre.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110926/ff836880/attachment.html
More information about the Qt-interest-old
mailing list