I've just been developing application in QtCreator with Qt5 for a short amount of time, and have just learned how to connect a signal with a slot. From what I understood, there are a few ways:
- Using the connect() method:
Using connect() method provided by QObject class :
connect(
sender, SIGNAL( valueChanged( QString, QString ) ),
receiver, SLOT( updateValue( QString ) )
);
Or with Qt5:
connect(
sender, &Sender::valueChanged,
receiver, &Receiver::updateValue
);
Clicking a widget in "Design" window, choosing "Go to slot..." and a function will be created. For example, choosing signal
Clicked()will generate the following code:void MainWindow::on_pushButton_clicked() { }Using "Edit Signal/Slot" mode directly in the "Design" window.
So my questions are:
- What's the standard way of connecting signals and slots?
- What's the point of other method? And when do we use those?
Sources: Qt connect method