using invokeMethod for menu addAction
For various reasons I would like to move my creation of menu actions to a thread. I thought I should be able to do this with "invokeMethod", but I am having problems.
Essentially, I would like to replace this code
Code:
blah = ui->menuCurves->addAction("ActionText");
with this code
Code:
Qt
::QueuedConnection, Q_RETURN_ARG
(QAction*, blah
), Q_ARG
(QString,
"ActionText"));
Using invokeMethod, the code runs but 'blah' is not a valid pointer and nothing is added to the 'menuCurves' menu.
I feel like I am close, but what is wrong???
Re: using invokeMethod for menu addAction
Using invokeMethod() with Qt::QueuedConnection does not do anything in a thread. It is just a delayed invokation. And I don't see how you'd like to access that "blah" pointer since it will only be valid after the method is executed (and only if you made the method a slot or otherwise invokable).