Standard way of connecting signal and slot within Qt

Viewed 211

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:

  1. 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
);
  1. 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() { }

  2. Using "Edit Signal/Slot" mode directly in the "Design" window.

So my questions are:

  1. What's the standard way of connecting signals and slots?
  2. What's the point of other method? And when do we use those?

Sources: Qt connect method

0 Answers
Related