|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QGroupBox
public class QGroupBox
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. |
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.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 event handler can be reimplemented to handle state changes. |
protected void |
childEvent(QChildEvent event)
This event handler can be reimplemented in a subclass to receive child events. |
boolean |
event(QEvent event)
This is the main event handler; it handles event arg__1. |
protected void |
focusInEvent(QFocusEvent event)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. |
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()
Returns the recommended minimum size for the widget. |
protected void |
mouseMoveEvent(QMouseEvent event)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse move events for the widget. |
protected void |
mousePressEvent(QMouseEvent event)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget. |
protected void |
mouseReleaseEvent(QMouseEvent event)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse release events for the widget. |
protected void |
paintEvent(QPaintEvent event)
This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter. |
protected void |
resizeEvent(QResizeEvent event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter. |
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.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 |
---|
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.
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.
Constructor Detail |
---|
public QGroupBox()
Equivalent to QGroupBox(0).
public QGroupBox(QWidget parent)
Constructs a group box widget with the given parent but with no title.
public QGroupBox(java.lang.String title)
Equivalent to QGroupBox(title, 0).
public QGroupBox(java.lang.String title, QWidget parent)
Constructs a group box with the given title and parent.
Method Detail |
---|
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.
Qt::Alignment
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.
checked
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.
checkable
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.
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.
Qt::Alignment
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.
checked
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.
checkable
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.
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.
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.
protected void changeEvent(QEvent event)
This event handler can be reimplemented to handle state changes.
The state being changed in this event can be retrieved through event arg__1.
Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange.
changeEvent
in class QWidget
protected void childEvent(QChildEvent event)
This event handler can be reimplemented in a subclass to receive child events. The event is passed in the arg__1 parameter.
QEvent::ChildAdded and QEvent::ChildRemoved events are sent to objects when children are added or removed. In both cases you can only rely on the child being a QObject, or if isWidgetType returns true, a QWidget. (This is because, in the ChildAdded case, the child is not yet fully constructed, and in the ChildRemoved case it might have been destructed already).
QEvent::ChildPolished events are sent to widgets when children are polished, or when polished children are added. If you receive a child polished event, the child's construction is usually completed.
For every child widget, you receive one ChildAdded event, zero or more ChildPolished events, and one ChildRemoved event.
The ChildPolished event is omitted if a child is removed immediately after it is added. If a child is polished several times during construction and destruction, you may receive several child polished events for the same child, each time with a different virtual table.
childEvent
in class QObject
public boolean event(QEvent event)
This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.
Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.
Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.
This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.
event
in class QWidget
protected void focusInEvent(QFocusEvent event)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. The event is passed in the arg__1 parameter
A widget normally must setFocusPolicy to something other than Qt::NoFocus in order to receive focus events. (Note that the application programmer can call setFocus on any widget, even those that do not normally accept focus.)
The default implementation updates the widget (except for windows that do not specify a focusPolicy).
focusInEvent
in class QWidget
public QSize minimumSizeHint()
Returns the recommended minimum size for the widget.
If the value of this property is an invalid size, no minimum size is recommended.
The default implementation of minimumSizeHint returns an invalid size if there is no layout for this widget, and returns the layout's minimum size otherwise. Most built-in widgets reimplement minimumSizeHint.
QLayout will never resize a widget to a size smaller than the minimum size hint unless minimumSize is set or the size policy is set to QSizePolicy::Ignore. If minimumSize is set, the minimum size hint will be ignored.
minimumSizeHint
in class QWidget
protected void mouseMoveEvent(QMouseEvent event)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse move events for the widget.
If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not Qt.
mouseMoveEvent
in class QWidget
Example
protected void mousePressEvent(QMouseEvent event)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget.
If you create new widgets in the mousePressEvent the mouseReleaseEvent may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.
The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.
mousePressEvent
in class QWidget
Example
protected void mouseReleaseEvent(QMouseEvent event)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse release events for the widget.
mouseReleaseEvent
in class QWidget
Example
protected void paintEvent(QPaintEvent event)
This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.
Qt also tries to speed up painting by merging multiple paint events into one. When update is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint does not permit this optimization, so we suggest using update whenever possible.
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.
The background can be set using setBackgroundRole and setPalette.
From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.
Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:
... extern void qt_x11_set_global_double_buffer(bool); qt_x11_set_global_double_buffer(false); ...
Note: In general, one should refrain from calling update or repaint inside of paintEvent. For example, calling update or repaint on children inside a paintEvent results in undefined behavior; the child may or may not get a paint event.
paintEvent
in class QWidget
protected void resizeEvent(QResizeEvent event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter. When resizeEvent is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
resizeEvent
in class QWidget
Example
public static QGroupBox fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.protected final void initStyleOption(QStyleOptionGroupBox option)
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |