Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I added a QPushButton to my ui file named pushButton, and manually connected it using connect. There are no errors or warnings emitted at any point in the compilation stage The button does show up...
#1: Initial revision
connect with SLOT/SIGNAL: QPushButton clicked signal not received by main window
I added a `QPushButton` to my ui file named `pushButton`, and manually connected it using `connect`. - There are no errors or warnings emitted at any point in the compilation stage - The button does show up on the UI. - When I click on the button, nothing happens. MainWindow.cpp: ``` #include "mainwindow.h" #include "ui_mainwindow.h" #include <QMessageBox> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(pushButton_Clicked)); } MainWindow::~MainWindow() { delete ui; } void MainWindow::pushButton_Clicked() { QMessageBox::information(nullptr, tr("Status"), tr("You clicked the button!")); } ``` MainWindow.h ``` #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; private slots: void pushButton_Clicked(); }; #endif // MAINWINDOW_H ``` What do I need to do to make `MainWindow::pushButton_Clicked()` get called when the button is clicked?