Qt visual studio signal slot

broken image
broken image

When you use the SLOT() macro, you aren't passing in a function pointer, it actually stringizes what you pass in behind the scenes. With this syntax, the button clicked() signal will be received by MainWindow. When specifying a slot in the connect function, it's required to put parenthesis, so the correct code would be: connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(pushButton_Clicked())) Qt's SLOT macro is very specific in what it accepts. What do I need to do to make MainWindow::pushButton_Clicked() get called when the button is clicked? QMessageBox::information(nullptr, tr('Status'), tr('You clicked the button!')) Įxplicit MainWindow(QWidget *parent = 0) MainWindow::MainWindow(QWidget *parent) :Ĭonnect(ui->pushButton, SIGNAL(clicked()), this, SLOT(pushButton_Clicked)) When I click on the button, nothing happens.There are no errors or warnings emitted at any point in the compilation stage.

broken image

I added a QPushButton to my ui file named pushButton, and manually connected it using connect.

broken image