Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QGroupBox Class

TheQGroupBox widget provides a group box frame with a title.More...

Header:#include <QGroupBox>
Inherits:QWidget
Inherited By:

Q3GroupBox

Properties

Public Functions

QGroupBox(QWidget * parent = 0)
QGroupBox(const QString & title, QWidget * parent = 0)
~QGroupBox()
Qt::Alignmentalignment() const
boolisCheckable() const
boolisChecked() const
boolisFlat() const
voidsetAlignment(int alignment)
voidsetCheckable(bool checkable)
voidsetFlat(bool flat)
voidsetTitle(const QString & title)
QStringtitle() const

Reimplemented Public Functions

virtual QSizeminimumSizeHint() const

Public Slots

voidsetChecked(bool checked)
  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject

Signals

voidclicked(bool checked = false)
voidtoggled(bool on)

Protected Functions

voidinitStyleOption(QStyleOptionGroupBox * option) const

Reimplemented Protected Functions

virtual voidchangeEvent(QEvent * ev)
virtual voidchildEvent(QChildEvent * c)
virtual boolevent(QEvent * e)
virtual voidfocusInEvent(QFocusEvent * fe)
virtual voidmouseMoveEvent(QMouseEvent * event)
virtual voidmousePressEvent(QMouseEvent * event)
virtual voidmouseReleaseEvent(QMouseEvent * event)
virtual voidpaintEvent(QPaintEvent * event)
virtual voidresizeEvent(QResizeEvent * e)
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 1 protected slot inherited fromQWidget

Detailed Description

TheQGroupBox 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 thetitle (normally set in the constructor) and the title'salignment. Group boxes can becheckable; child widgets in checkable group boxes are enabled or disabled depending on whether or not the group box ischecked.

You can minimize the space consumption of a group box by enabling theflat property. In moststyles, 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 oftenQCheckBoxes orQRadioButtons but can be any widgets). The following example shows how we can set up aQGroupBox with a layout:

QGroupBox*groupBox=newQGroupBox(tr("Exclusive Radio Buttons"));QRadioButton*radio1=newQRadioButton(tr("&Radio button 1"));QRadioButton*radio2=newQRadioButton(tr("R&adio button 2"));QRadioButton*radio3=newQRadioButton(tr("Ra&dio button 3"));    radio1->setChecked(true);QVBoxLayout*vbox=newQVBoxLayout;    vbox->addWidget(radio1);    vbox->addWidget(radio2);    vbox->addWidget(radio3);    vbox->addStretch(1);    groupBox->setLayout(vbox);
Screenshot of a Windows XP style group boxScreenshot of a Macintosh style group boxScreenshot of a Plastique style group box
AWindows XP style group box.AMacintosh style group box.APlastique style group box.

See alsoQButtonGroup andGroup Box Example.

Property Documentation

alignment :Qt::Alignment

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:

  • Qt::AlignLeft aligns the title text with the left-hand side of the group box.
  • Qt::AlignRight aligns the title text with the right-hand side of the group box.
  • Qt::AlignHCenter aligns the title text with the horizontal center of the group box.

The default alignment isQt::AlignLeft.

Access functions:

Qt::Alignmentalignment() const
voidsetAlignment(int alignment)

See alsoQt::Alignment.

checkable :bool

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:

boolisCheckable() const
voidsetCheckable(bool checkable)

See alsochecked.

checked :bool

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:

boolisChecked() const
voidsetChecked(bool checked)

Notifier signal:

voidtoggled(bool on)

See alsocheckable.

flat :bool

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:

boolisFlat() const
voidsetFlat(bool flat)

See alsotitle.

title :QString

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 theQShortcut documentation for details (to display an actual ampersand, use '&&').

There is no default title text.

Access functions:

QStringtitle() const
voidsetTitle(const QString & title)

See alsoalignment.

Member Function Documentation

QGroupBox::QGroupBox(QWidget * parent = 0)

Constructs a group box widget with the givenparent but with no title.

QGroupBox::QGroupBox(constQString & title,QWidget * parent = 0)

Constructs a group box with the giventitle andparent.

QGroupBox::~QGroupBox()

Destroys the group box.

[virtual protected]void QGroupBox::changeEvent(QEvent * ev)

Reimplemented fromQWidget::changeEvent().

[virtual protected]void QGroupBox::childEvent(QChildEvent * c)

Reimplemented fromQObject::childEvent().

[signal]void QGroupBox::clicked(bool checked = false)

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 isnot emitted if you callsetChecked().

If the check box is checkedchecked is true; it is false if the check box is unchecked.

This function was introduced in Qt 4.2.

See alsocheckable,toggled(), andchecked.

[virtual protected]bool QGroupBox::event(QEvent * e)

Reimplemented fromQObject::event().

[virtual protected]void QGroupBox::focusInEvent(QFocusEvent * fe)

Reimplemented fromQWidget::focusInEvent().

[protected]void QGroupBox::initStyleOption(QStyleOptionGroupBox * option) const

Initializeoption with the values from thisQGroupBox. This method is useful for subclasses when they need aQStyleOptionGroupBox, but don't want to fill in all the information themselves.

See alsoQStyleOption::initFrom().

[virtual]QSize QGroupBox::minimumSizeHint() const

Reimplemented fromQWidget::minimumSizeHint().

[virtual protected]void QGroupBox::mouseMoveEvent(QMouseEvent * event)

Reimplemented fromQWidget::mouseMoveEvent().

[virtual protected]void QGroupBox::mousePressEvent(QMouseEvent * event)

Reimplemented fromQWidget::mousePressEvent().

[virtual protected]void QGroupBox::mouseReleaseEvent(QMouseEvent * event)

Reimplemented fromQWidget::mouseReleaseEvent().

[virtual protected]void QGroupBox::paintEvent(QPaintEvent * event)

Reimplemented fromQWidget::paintEvent().

[virtual protected]void QGroupBox::resizeEvent(QResizeEvent * e)

Reimplemented fromQWidget::resizeEvent().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp