dwizard
27th June 2013, 04:38
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"); with this code
QMetaObject::invokeMethod(ui->menuCurves, "addAction",
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???
Essentially, I would like to replace this code
blah = ui->menuCurves->addAction("ActionText"); with this code
QMetaObject::invokeMethod(ui->menuCurves, "addAction",
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???