The Interface Design of QT is similar to that of VC.

Source: Internet
Author: User
Pushbutton, radiobutton, and checkbox control

Http://book.51cto.com/art/201203/323282.htm

3. Example implementation

Here we use the slot function automatically generated by QT creator, without the need to write the ing between signals and slot functions. (QT creator automatically generates a slot function: Right-click the control → go to slot, and select the corresponding signal function of the slot function, after confirmation, the slot function declaration and definition framework will be generated .)

 
Figure 3-14 select a signal

Right-click the radiobutton control, select the go to slot option, and select the signal in the signal window, as shown in Figure 3-14. In this example, we use the clicked () signal. After confirmation, it will jump to the definition framework of the slot function. The slot function declaration has been automatically generated, which is similar to winform. Then you only need to fill in the slot function.

Add slots for controls radiobutton_2, radiobutton_3, checkbox, checkbox_2, checkbox_3, btn_radiobutton, and btn_checkbox in the same way.

After the project is created and the corresponding control properties, signals, and slot functions are compiled, edit the corresponding file.

Mainwindow. H (bold in the text indicates the content to be added ):

 
 
 
  1. # Ifndef mainwindow_h
  2. # Define mainwindow_h
  3. # Include <qmainwindow>
  4. Namespace UI {
  5. Class mainwindow;
  6. }
  7. Class mainwindow: Public qmainwindow
  8. {
  9. Q_object
  10. Public:
  11. Explicit mainwindow (qwidget * parent = 0 );
  12. ~ Mainwindow ();
  13. Void displaycheckbox ();
  14. PRIVATE:
  15. Ui: mainwindow * UI;
  16. Private slots: // slot function, automatically added
  17. Void on_checkbox_3_clicked ();
  18. Void on_checkbox_2_clicked ();
  19. Void on_checkbox_clicked ();
  20. Void on_radiobutton_3_clicked ();
  21. Void on_radiobutton_2_clicked ();
  22. Void on_radiobutton_clicked ();
  23. Void on_btn_checkbox_clicked ();
  24. Void on_btn_radiobutton_clicked ();
  25. };
  26. # Endif // mainwindow_h

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.