User Tools

Site Tools


qt:wiring_up_signals_and_slots

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
qt:wiring_up_signals_and_slots [2011/03/31 15:07] mithatqt:wiring_up_signals_and_slots [2011/04/01 11:12] mithat
Line 16: Line 16:
  
 A handler you make this way for a ''button_quit'' widget might look like: A handler you make this way for a ''button_quit'' widget might look like:
-<code cpp>+<code cpp-qt>
 void MainWindow::on_button_quit_clicked() void MainWindow::on_button_quit_clicked()
 { {
Line 23: Line 23:
  
 The handlers you create this way are actually a private slots. You can confirm this by looking at the header file for the class you are editing: The handlers you create this way are actually a private slots. You can confirm this by looking at the header file for the class you are editing:
-<code cpp>+<code cpp-qt>
 private slots: private slots:
     void on_button_quit_clicked();</code>     void on_button_quit_clicked();</code>
Line 29: Line 29:
 === Behind the scenes === === Behind the scenes ===
 How does the build system know that that ''button_quit'''s ''clicked()'' signal connects to ''MainWindow'''s ''on_button_quit_event_clicked()'' slot? It appears that the connection between signals and slots created this way is done purely via a naming convention along the following lines: How does the build system know that that ''button_quit'''s ''clicked()'' signal connects to ''MainWindow'''s ''on_button_quit_event_clicked()'' slot? It appears that the connection between signals and slots created this way is done purely via a naming convention along the following lines:
-<code cpp><widget-name> <signal-name>()</code> automatically connects to any slot of the form <code cpp><ClassName>::on_<widget-name>_<signal-name>()</code>+<code cpp-qt><widget-name> <signal-name>()</code> automatically connects to any slot of the form <code cpp-qt><ClassName>::on_<widget-name>_<signal-name>()</code>
 == Question == == Question ==
 If the above is true, then it should be possible to create event handlers just by writing code. Two tests are indicated: If the above is true, then it should be possible to create event handlers just by writing code. Two tests are indicated:
Line 110: Line 110:
 You can explicitly connect signals and slots programatically. This is typically done in a form's constructor.  You can explicitly connect signals and slots programatically. This is typically done in a form's constructor. 
  
-<code cpp>+<code cpp-qt>
 HelloForm::HelloForm() HelloForm::HelloForm()
 { {
qt/wiring_up_signals_and_slots.txt · Last modified: 2011/04/03 13:14 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki