Qt Jambi Home

com.trolltech.qt.gui
Class QGroupBox

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QGroupBox
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QGroupBox
extends QWidget

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);

Screenshot of a Windows XP style group boxScreenshot of a Macintosh style group boxScreenshot of a Plastique style group box
A Windows XP style group box.A Macintosh style group box.A Plastique style group box.

See Also:
QButtonGroup, Box Example

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<java.lang.Boolean> clicked
          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.
 QSignalEmitter.Signal1<java.lang.Boolean> toggled
          If the group box is checkable, this signal is emitted when the check box is toggled.
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QGroupBox()
          Equivalent to QGroupBox(0).
QGroupBox(QWidget parent)
          Constructs a group box widget with the given parent but with no title.
QGroupBox(java.lang.String title)
          Equivalent to QGroupBox(title, 0).
QGroupBox(java.lang.String title, QWidget parent)
          Constructs a group box with the given title and parent.
 
Method Summary
 Qt.Alignment alignment()
          Returns the alignment of the group box title..
protected  void changeEvent(QEvent event)
          This function is reimplemented for internal reasons.
protected  void childEvent(QChildEvent event)
          This function is reimplemented for internal reasons.
 boolean event(QEvent event)
          This function is reimplemented for internal reasons.
protected  void focusInEvent(QFocusEvent event)
          This function is reimplemented for internal reasons.
static QGroupBox fromNativePointer(QNativePointer nativePointer)
          This function returns the QGroupBox instance pointed to by nativePointer
protected  void initStyleOption(QStyleOptionGroupBox option)
          Initialize option with the values from this QGroupBox.
 boolean isCheckable()
          Returns whether the group box has a checkbox in its title.
 boolean isChecked()
          Returns whether the group box is checked.
 boolean isFlat()
          Returns whether the group box is painted flat or has a frame.
 QSize minimumSizeHint()
          This function is reimplemented for internal reasons.
protected  void mouseMoveEvent(QMouseEvent event)
          This function is reimplemented for internal reasons.
protected  void mousePressEvent(QMouseEvent event)
          This function is reimplemented for internal reasons.
protected  void mouseReleaseEvent(QMouseEvent event)
          This function is reimplemented for internal reasons.
protected  void paintEvent(QPaintEvent event)
          This function is reimplemented for internal reasons.
protected  void resizeEvent(QResizeEvent event)
          This function is reimplemented for internal reasons.
 void setAlignment(int alignment)
          Sets the alignment of the group box title.
 void setCheckable(boolean checkable)
          Sets whether the group box has a checkbox in its title to checkable.
 void setChecked(boolean checked)
          Sets whether the group box is checked to checked.
 void setFlat(boolean flat)
          Sets whether the group box is painted flat or has a frame to flat.
 void setTitle(java.lang.String title)
          Sets the group box title text to title.
 java.lang.String title()
          Returns the group box title text.
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseDoubleClickEvent, mouseGrabber, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

clicked

public final QSignalEmitter.Signal1<java.lang.Boolean> clicked

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.

Compatible Slot Signatures:
void mySlot(boolean checked)
void mySlot()
See Also:
checkable, toggled, checked


toggled

public final QSignalEmitter.Signal1<java.lang.Boolean> toggled

If the group box is checkable, this signal is emitted when the check box is toggled. arg__1 is true if the check box is checked; otherwise it is false.

Compatible Slot Signatures:
void mySlot(boolean arg__1)
void mySlot()
See Also:
checkable

Constructor Detail

QGroupBox

public QGroupBox()

Equivalent to QGroupBox(0).


QGroupBox

public QGroupBox(QWidget parent)

Constructs a group box widget with the given parent but with no title.


QGroupBox

public QGroupBox(java.lang.String title)

Equivalent to QGroupBox(title, 0).


QGroupBox

public QGroupBox(java.lang.String title,
                 QWidget parent)

Constructs a group box with the given title and parent.

Method Detail

alignment

public final Qt.Alignment alignment()

Returns 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.

See Also:
setAlignment, Qt::Alignment

isCheckable

public final boolean isCheckable()

Returns 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.

See Also:
checked

isChecked

public final boolean isChecked()

Returns 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.

See Also:
checkable

isFlat

public final boolean isFlat()

Returns 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.

See Also:
title

setAlignment

public final void setAlignment(int alignment)

Sets the alignment of the group box title. to alignment.

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.

See Also:
alignment, Qt::Alignment

setCheckable

public final void setCheckable(boolean checkable)

Sets whether the group box has a checkbox in its title to checkable.

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.

See Also:
isCheckable, checked

setChecked

public final void setChecked(boolean checked)

Sets whether the group box is checked to 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.

See Also:
isChecked, checkable

setFlat

public final void setFlat(boolean flat)

Sets whether the group box is painted flat or has a frame to flat.

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.

See Also:
isFlat, title

setTitle

public final void setTitle(java.lang.String title)

Sets the group box title text to title.

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.

See Also:
title, alignment

title

public final java.lang.String title()

Returns 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.

See Also:
setTitle, alignment

changeEvent

protected void changeEvent(QEvent event)

This function is reimplemented for internal reasons.

Overrides:
changeEvent in class QWidget

childEvent

protected void childEvent(QChildEvent event)

This function is reimplemented for internal reasons.

Overrides:
childEvent in class QObject
See Also:
event

event

public boolean event(QEvent event)

This function is reimplemented for internal reasons.

Overrides:
event in class QWidget
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

focusInEvent

protected void focusInEvent(QFocusEvent event)

This function is reimplemented for internal reasons.

Overrides:
focusInEvent in class QWidget
See Also:
focusOutEvent, setFocusPolicy, keyPressEvent, keyReleaseEvent, event, QFocusEvent

minimumSizeHint

public QSize minimumSizeHint()

This function is reimplemented for internal reasons.

Overrides:
minimumSizeHint in class QWidget
See Also:
QSize::isValid, resize, setMinimumSize, sizePolicy

mouseMoveEvent

protected void mouseMoveEvent(QMouseEvent event)

This function is reimplemented for internal reasons.

Overrides:
mouseMoveEvent in class QWidget
See Also:
setMouseTracking, mousePressEvent, mouseReleaseEvent, mouseDoubleClickEvent, event, QMouseEvent, Example

mousePressEvent

protected void mousePressEvent(QMouseEvent event)

This function is reimplemented for internal reasons.

Overrides:
mousePressEvent in class QWidget
See Also:
mouseReleaseEvent, mouseDoubleClickEvent, mouseMoveEvent, event, QMouseEvent, Example

mouseReleaseEvent

protected void mouseReleaseEvent(QMouseEvent event)

This function is reimplemented for internal reasons.

Overrides:
mouseReleaseEvent in class QWidget
See Also:
mousePressEvent, mouseDoubleClickEvent, mouseMoveEvent, event, QMouseEvent, Example

paintEvent

protected void paintEvent(QPaintEvent event)

This function is reimplemented for internal reasons.

Overrides:
paintEvent in class QWidget
See Also:
event, repaint, update, QPainter, QPixmap, QPaintEvent, Analog Clock Example

resizeEvent

protected void resizeEvent(QResizeEvent event)

This function is reimplemented for internal reasons.

Overrides:
resizeEvent in class QWidget
See Also:
moveEvent, event, resize, QResizeEvent, paintEvent, Example

fromNativePointer

public static QGroupBox fromNativePointer(QNativePointer nativePointer)
This function returns the QGroupBox instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

initStyleOption

protected final void initStyleOption(QStyleOptionGroupBox option)
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.


Qt Jambi Home