June 2019
Intermediate to advanced
348 pages
8h 28m
English
The quit slot of QApplication is provided by Qt, but if we want to open an image when clicking on the open action, which slot should we use? In this scenario, there's no slot built-in for this kind of customized task. We should write a slot on our own.
To write a slot, first we should declare a function in the body of the class, MainWindow, and place it in a slots section. As this function is not used by other classes, we put it in a private slots section, as follows:
private slots: void openImage();
Then, we give this slot (also a member function) a simple definition for testing:
void MainWindow::openImage() { qDebug() << "slot openImage is called."; }
Now, we connect the triggered signal of the open action to the openImage ...
Read now
Unlock full access