Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
How to add an Event? is a QT FAQ, especially for people with a C++ Builder background (like me): in C++ Builder the following steps were done for you automatically.
To add an Event (in Qt these are called 'slots'), three steps must be takes:
At the bottom of this page, a complete Qt Creator project can be downloaded.
The Event/slot must be declared in the dialog's header file. In the example below the slot 'MyEvent' is declared. All other code is default-created by Qt Creator.
#ifndef DIALOG_H |
The Event/slot must be defined in the dialog's implementation file. In the example below the slot 'MyEvent' is defined to changed the dialog's title. All other code is default-created by Qt Creator.
#include "dialog.h" |
Now that the Event/slot is declared, it must be specified what triggers its call. In Qt, Event/slots are triggered by a signal. In the example below the slot 'MyEvent' is set to be triggered (that is: connected) to the signal 'accepted()'. Note that this is a nearly-useless trigger: better would be something like a QPushButton's clicked() signal.
#include "dialog.h" |
Operating system: Ubuntu
IDE: Qt Creator 2.0.0
Project type: Qt4 GUI Application
Libraries used:
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.