Qt for beginners Exercise 1 basis: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(Redirect to Qt for Beginners (Merged))
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=Qt for beginners — Exercise 1 : basis=
#REDIRECT [[Qt for Beginners]]
 
[[Qt for beginners Signals and slots 2|<<< Signals and slots 2]] | [[Qt for beginners|Summary]] | [[Qt for beginners Doc|Finding information in the documentation >>>]]
 
'''''Note:''' Unfortunately, the images are no longer available. See the official [http://doc.qt.io/qt-5/gettingstartedqt.html Getting Started with Qt Widgets] ''[qt.io]'' page for an alternative tutorial.''
 
==Widgets==
 
Radio button is a standard <span class="caps">GUI</span> component. It is often used to make a unique choice from a list. In Qt, the [[doc/QRadioButton|QRadioButton]] is used to create radio buttons.
 
Thanks to a nice heritance, a QRadioButton just behaves like a QPushButton. All properties of the QPushButton are also the same in the QRadioButton, and everything that was learnt in the second chapter can be reused here
 
* text
* icon
* tooltip
* …
 
By default, QRadioButtons are not grouped, so many of them can be checked at the same time. In order to have the “exclusive” behaviour of many radio buttons, we need to use [[doc/QButtonGroup|QButtonGroup]]. This class can be used like this
 
What we want is to create a menu picker. In a window, a list of yummy plates should be displayed with radio buttons, and a push button that is used to select the chosen plate should be displayed.
 
Obviously, nothing will happen (now) when the buttons are clicked.
 
[[Image:7514416312_880b14d647.jpg|menu chooser]]
 
==Signals and slots==
 
Here is an example about signals and slots. We are going to write an application with two buttons. The first button should display information about Qt, like in the following dialog
 
[[Image:7503975304_5d67868890_b.jpg|About Qt]]
 
We provide you the following code to complete :
 
In order to display the information about Qt, you should use the following method
 
You can also add icons on the buttons, or resize them. Obviously, the “Quit” button should be more important, so why not make it bigger ?
 
The answers can be found [[Qt for beginners Exercise 1 answer|here]]. But we really recommend you to try and figure it out by yourself how to solve these exercises.
 
[[Qt for beginners Signals and slots 2|&lt;&lt;&lt; Signals and slots 2]] | [[Qt for beginners|Summary]] | [[Qt for beginners Doc|Finding information in the documentation &gt;&gt;&gt;]]
 
===Categories:===
 
* [[:Category:HowTo|HowTo]]
* [[:Category:Qt for beginners|Qt_for_beginners]]
* [[:Category:Tutorial|Tutorial]]

Latest revision as of 14:35, 5 May 2015

Redirect to: