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
blah = ui->menuCurves->addAction("ActionText");
blah = ui->menuCurves->addAction("ActionText");
To copy to clipboard, switch view to plain text mode
with this code
Qt
::QueuedConnection, Q_RETURN_ARG
(QAction*, blah
), Q_ARG
(QString,
"ActionText"));
QMetaObject::invokeMethod(ui->menuCurves, "addAction",
Qt::QueuedConnection, Q_RETURN_ARG(QAction*, blah), Q_ARG(QString, "ActionText"));
To copy to clipboard, switch view to plain text mode
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???
Bookmarks