I don't know how new signals and slots are created
Well, you instantiate a widget that can emit at least one signal (Qt's classes often include one or more signals, which you can find in the class documentation), and then you call QObject::connect() to associate that signal firing with some kind of consequence (usually a function call). Calls to connect() often happen inside a constructor method. A QPushButton quite naturally has a "clicked" signal for example, and we can make use of that signal like this:
QObject::connect(yourButton,
SIGNAL(clicked
()), someReceiverObject,
SLOT(onButtonClicked
()));
QObject::connect(yourButton, SIGNAL(clicked()), someReceiverObject, SLOT(onButtonClicked()));
To copy to clipboard, switch view to plain text mode
Now, whenever the button in question is clicked, someReceiverObject's onButtonClicked() function will be called. The onButtonClicked() function is like any other function except that it has been declared as a slot in the appropriate header file:
...
public slots:
void onButtonClicked(); // just an example, doesn't have to be void
...
...
public slots:
void onButtonClicked(); // just an example, doesn't have to be void
...
To copy to clipboard, switch view to plain text mode
I suggest reading and re-reading the documentation on signals and slots until you understand most of it. It might take some time to sink in. It might be an idea to hammer away at an introductory text or online tutorial for Object Oriented Programming concepts, too.
Bookmarks