Here is a "hello world" button that display a window and button. I would like to do a cout
or any other custom functionality when the button is clicked but I'm stuck.
#include <QApplication>
#include <QPushButton>
#include <iostream>
int main(int argc, char **argv){
// create app
QApplication app (argc, argv);
// create window
QWidget window;
window.setWindowTitle("MyWindow");
window.setFixedSize(600, 480);
// create button
QPushButton *button = new QPushButton(&window);
button->setGeometry(10, 10, 100, 35);
button->setText("hello!");
// event handling
// HERE IS THE PROBLEM
QObject::connect(button, SIGNAL(clicked()), ???, SLOT(???));
// show window
window.show();
}
How can I append a custom function to the SLOT? So I can console log stuff and handle the event on my own way? I can connect it to a QMediaPlayer for example to start/stop but I'm still very confused on how to use the signal/slot.