QGroupBox Class Reference |
QGroupBox ( QWidget * parent = 0 ) | |
QGroupBox ( const QString & title, QWidget * parent = 0 ) | |
~QGroupBox () | |
Qt::Alignment | alignment () const |
bool | isCheckable () const |
bool | isChecked () const |
bool | isFlat () const |
void | setAlignment ( int alignment ) |
void | setCheckable ( bool checkable ) |
void | setFlat ( bool flat ) |
void | setTitle ( const QString & title ) |
QString | title () const |
virtual QSize | minimumSizeHint () const |
void | setChecked ( bool checked ) |
void | clicked ( bool checked = false ) |
void | toggled ( bool on ) |
void | initStyleOption ( QStyleOptionGroupBox * option ) const |
virtual void | changeEvent ( QEvent * ev ) |
virtual void | childEvent ( QChildEvent * c ) |
virtual bool | event ( QEvent * e ) |
virtual void | focusInEvent ( QFocusEvent * fe ) |
virtual void | mouseMoveEvent ( QMouseEvent * event ) |
virtual void | mousePressEvent ( QMouseEvent * event ) |
virtual void | mouseReleaseEvent ( QMouseEvent * event ) |
virtual void | paintEvent ( QPaintEvent * event ) |
virtual void | resizeEvent ( QResizeEvent * e ) |
The QGroupBox widget provides a group box frame with a title.
A group box provides a frame, a title and a keyboard shortcut, and displays various other widgets inside itself. The title is on top, the keyboard shortcut moves keyboard focus to one of the group box's child widgets.
QGroupBox also lets you set the title (normally set in the constructor) and the title's alignment. Group boxes can be checkable; child widgets in checkable group boxes are enabled or disabled depending on whether or not the group box is checked.
You can minimize the space consumption of a group box by enabling the flat property. In most styles, enabling this property results in the removal of the left, right and bottom edges of the frame.
QGroupBox doesn't automatically lay out the child widgets (which are often QCheckBoxes or QRadioButtons but can be any widgets). The following example shows how we can set up a QGroupBox with a layout:
QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons")); QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1")); QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2")); QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3")); radio1->setChecked(true); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(radio1); vbox->addWidget(radio2); vbox->addWidget(radio3); vbox->addStretch(1); groupBox->setLayout(vbox);
A Windows XP style group box. | A Macintosh style group box. | A Plastique style group box. |
See also QButtonGroup and Group Box Example.
This property holds the alignment of the group box title.
Most styles place the title at the top of the frame. The horizontal alignment of the title can be specified using single values from the following list:
The default alignment is Qt::AlignLeft.
Access functions:
Qt::Alignment | alignment () const |
void | setAlignment ( int alignment ) |
See also Qt::Alignment.
This property holds whether the group box has a checkbox in its title.
If this property is true, the group box displays its title using a checkbox in place of an ordinary label. If the checkbox is checked, the group box's children are enabled; otherwise they are disabled and inaccessible.
By default, group boxes are not checkable.
If this property is enabled for a group box, it will also be initially checked to ensure that its contents are enabled.
Access functions:
bool | isCheckable () const |
void | setCheckable ( bool checkable ) |
See also checked.
This property holds whether the group box is checked.
If the group box is checkable, it is displayed with a check box. If the check box is checked, the group box's children are enabled; otherwise the children are disabled and are inaccessible to the user.
By default, checkable group boxes are also checked.
Access functions:
bool | isChecked () const |
void | setChecked ( bool checked ) |
Notifier signal:
void | toggled ( bool on ) |
See also checkable.
This property holds whether the group box is painted flat or has a frame.
A group box usually consists of a surrounding frame with a title at the top. If this property is enabled, only the top part of the frame is drawn in most styles; otherwise the whole frame is drawn.
By default, this property is disabled; i.e. group boxes are not flat unless explicitly specified.
Note: In some styles, flat and non-flat group boxes have similar representations and may not be as distinguishable as they are in other styles.
Access functions:
bool | isFlat () const |
void | setFlat ( bool flat ) |
See also title.
This property holds the group box title text.
The group box title text will have a keyboard shortcut if the title contains an ampersand ('&') followed by a letter.
g->setTitle("&User information");
In the example above, Alt+U moves the keyboard focus to the group box. See the QShortcut documentation for details (to display an actual ampersand, use '&&').
There is no default title text.
Access functions:
QString | title () const |
void | setTitle ( const QString & title ) |
See also alignment.
Constructs a group box widget with the given parent but with no title.
Constructs a group box with the given title and parent.
Destroys the group box.
Reimplemented from QWidget::changeEvent().
Reimplemented from QObject::childEvent().
This signal is emitted when the check box is activated (i.e. pressed down then released while the mouse cursor is inside the button), or when the shortcut key is typed, Notably, this signal is not emitted if you call setChecked().
If the check box is checked checked is true; it is false if the check box is unchecked.
This function was introduced in Qt 4.2.
See also checkable, toggled(), and checked.
Reimplemented from QObject::event().
Reimplemented from QWidget::focusInEvent().
Initialize option with the values from this QGroupBox. This method is useful for subclasses when they need a QStyleOptionGroupBox, but don't want to fill in all the information themselves.
See also QStyleOption::initFrom().
Reimplemented from QWidget::minimumSizeHint().
Reimplemented from QWidget::mouseMoveEvent().
Reimplemented from QWidget::mousePressEvent().
Reimplemented from QWidget::mouseReleaseEvent().
Reimplemented from QWidget::paintEvent().
Reimplemented from QWidget::resizeEvent().
If the group box is checkable, this signal is emitted when the check box is toggled. on is true if the check box is checked; otherwise it is false.
See also checkable.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.6 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com