[Solved] Signal/slot doesn’t work
I am practicing Qt5 and I tried some easy signal/slots which worked, but now I tried to open a Dialogwindow with a connect and it doesn't work. I really don't know why.. I tried to open only the window in the main and it worked, so the problem comes probably from the connect line.
@class MaFenetre: public QWidget
cadre = new QWidget;
bouton2 = new QPushButton("Question!",cadre);
QObject::connect(bouton2, SIGNAL(clicked()), this , SLOT(OuvrirDialogueQuestion()));
QMessageBox::question(this,"Question","Est ce que tu aimes les nems?", QMessageBox::Yes | QMessageBox::No);
@int main (int argc, char *argv)
QApplication app(argc, argv);
Would anyone have an idea about where the error could be? If you have any advice about this program, I would be interested to read them too. Thank you in advance!
Oups sorry I am not in the good topic folder, but I don't know how to delete my topic
mranger90 last edited by
You need a Q_OBJECT designation in your class declaration.
class MaFenetre: public QWidget
Be sure and add a Q_OBJECT macro in your class. You may need to run qmake again, too.
[Edit: Oops, didn't see mranger90's response.]
Thank you very much, it works now!
Good deal! Be sure and edit your first post to add [Solved] to the beginning of the title! Thanks!