I would like to know if I created a button not through a GUI, but usually by typing it:

QPushButton *ledButton = new QPushButton("LED Button"); layout->addWidget(ledButton); 

How to connect this code?

 void MainWindow::on_ledButton_clicked() { } 

1 answer 1

Connection Code

 connect (ledButton, SIGNAL(clicked()), this, SLOT(on_ledButton_clicked())); 
  • The on_ledButton_clicked method should be declared as public slots - Mikhail Bubnov