Qt 6.11 is out! See what's new in the release
blog
Slot parameter for QMetaObject::invokeMethod
-
Playing with
QMetaObject::invokeMethodmethod :#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::setText( int value) { QString s = QString::number(value); ui->textEdit->setText(s); } void MainWindow::on_pushButton_clicked() { QGenericArgument genericArg = Q_ARG(int, 321); bool inv = QMetaObject::invokeMethod( this,"setText",Qt::BlockingQueuedConnection, genericArg); qDebug("inv = %d\n", inv); }QMetaObject::invokeMethodreturns false.I'm not sure regarding slot
"setText". I took it from function name and I suppose it might be related. Where I can find list of slots at all? Should I create special slot for"setText"?Maybe it is related to fact I run it from the same thread?
-
Hi
A slot is a ordinary c++ member method.
For it to be a slot it should be listed under slots:class MainWindow: public QMainWindow { Q_OBJECT public: private slots: void MachineStatusClicked(); public slots: void ShowOrderList(); private:so make sure you method is marked as a slot.