Greetings, everyone!
I've got a class that represents kind of a tool bar. To add an action, I've managed to provide the following two methods:
QAction* addAction(QString title, QObject* receiver, char* slot);
QAction* addAction(QString title, std::function<void()> functor);
To copy to clipboard, switch view to plain text mode
These methods allow me to do things like these:
theToolBar->addAction("foo", theReceiver, SLOT(theSlot()));
theToolBar->addAction("bar", [](){ bar(); })
theToolBar->addAction("foo", theReceiver, SLOT(theSlot()));
theToolBar->addAction("bar", [](){ bar(); })
To copy to clipboard, switch view to plain text mode
Now one thing I did not accomplish: Use the new cool C++11-signal-slot-syntax!
I'd like to write my code like this:
theToolBar->addAction("foobar", theReceiver, &TheReceiverClass::theSlot)
theToolBar->addAction("foobar", theReceiver, &TheReceiverClass::theSlot)
To copy to clipboard, switch view to plain text mode
But how would the signature of the new overload of addAction look like?
I would appreciate any help. (Quite honestly, this wouldn't be an important fetaure at all but at least it would be consistent.)
Maximilian
Bookmarks