Qt Signal Slot
-
Hello everyone, I am very new at Qt C++ and trying to understand the logic of signal slot. What I wanted to implement is the following;
-When user on click the button, the external pyhton code that I wanted to run will be run.I have seen this post --> http://www.qtforum.org/article/3773/when-pushbutton-click-qprocess-start.html?s=ddaff16695b9e225ee8a5f07c46f9e8d0f26d5df#post16206 .
Here is my code part;public slots: void startProcess(); signals: void clicked(); connect(ui->button, SIGNAL(clicked()),this, SLOT(startProcess())); void MainWindow::startProcess(){ QProcess process; process.setWorkingDirectory("home/giz/Documents"); process.setProgram("python helloworld.py"); process.start("python helloworld.py"); process.waitForFinished(1000); }
When I run the code I am getting the following error;
QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
Which one is wrong? My signal slot logic or qprocess usage?
-
Hi @gizalp
Maybe somewhere on your code you have a slot named on_pushButton_clicked(), and this kind of name is used for QMetaObject::connectSlotsByName,
If you have a slot with the name on_pushButton_clicked() , try just to rename it to onPushButtonClicked() !
-
@gizalp said in Qt Signal Slot:
When I run the code I am getting the following error;
QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()Which one is wrong? My signal slot logic or qprocess usage?
seems like you created a pushbutton in QtDesigner, right cliked it and added Signal/Slot mechanismn that created a
on_pushButton_clicked()
function in your MainWindow class.
You either went and renamed the button in the designer-form or deleted the function or something like that.However a clean rebuild should fix that for you