Classes - Annotated - Tree - Functions - Home - Structure

QGroupBox Class Reference

The QGroupBox widget provides a group box frame with a title. More...

#include <qgroupbox.h>

Inherits QFrame.

Inherited by QButtonGroup, QHGroupBox and QVGroupBox.

List of all member functions.

Public Members

Properties

Protected Members


Detailed Description

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, and the child widgets are arranged in an array inside the frame.

The simplest way to use it is to create a group box with the desired number of columns and orientation, and then just create widgets with the group box as parent.

However, it is also possible to change the orientation() and number of columns() after construction, or to ignore all the automatic layout support and manage all that yourself.

QGroupBox also lets you set the title() (normally set in the constructor) and the title's alignment().

See also QButtonGroup.


Member Function Documentation

QGroupBox::QGroupBox ( QWidget * parent = 0, const char * name = 0 )

Constructs a group box widget with no title.

The parent and name arguments are passed to the QWidget constructor.

This constructor does not do automatic layout.

QGroupBox::QGroupBox ( const QString & title, QWidget * parent = 0, const char * name = 0 )

Constructs a group box with a title.

The parent and name arguments are passed to the QWidget constructor.

This constructor does not do automatic layout.

QGroupBox::QGroupBox ( int strips, Orientation orientation, QWidget * parent = 0, const char * name = 0 )

Constructs a group box with no title. Child widgets will be arranged in strips rows or columns (depending on orientation).

The parent and name arguments are passed to the QWidget constructor.

QGroupBox::QGroupBox ( int strips, Orientation orientation, const QString & title, QWidget * parent = 0, const char * name = 0 )

Constructs a group box titled title. Child widgets will be arranged in strips rows or columns (depending on orientation).

The parent and name arguments are passed to the QWidget constructor.

void QGroupBox::addSpace ( int size )

Adds an empty cell at the next free position. If size is greater than 0, the empty cell has a fixed height or width. If the group box is oriented horizontally, the empty cell has a fixed height; if oriented vertically, it has a fixed width.

Use this method to separate the widgets in the group box or to skip the next free cell. For performance reasons, call this method after calling setColumnLayout() or by changing the QGroupBox::columns or QGroupBox::orientation properties. It is generally a good idea to call these methods first (if needed at all), and insert the widgets and spaces afterwards.

int QGroupBox::alignment () const

Returns the alignment of the group box title. See the "alignment" property for details.

int QGroupBox::columns () const

Returns the number of columns in the group box. See the "columns" property for details.

int QGroupBox::insideMargin () const

Returns the width of the blank spacing between the items in the group and the frame of the group.

Only applies if the groupbox has an defined orientation.

The default is about 11.

See also setInsideMargin() and orentiation().

int QGroupBox::insideSpacing () const

Returns the width of the blank spacing between each of the items in the group.

Only applies if the groupbox has an defined orientation.

The default is about 5.

See also setInsideSpacing() and orentiation().

Orientation QGroupBox::orientation () const

Returns the current orientation of the group box. See the "orientation" property for details.

void QGroupBox::setColumnLayout ( int columns, Orientation direction ) [virtual]

Changes the layout of the group box. This function is useful only in combination with the default constructor that does not take any layout information. This function will put all existing children in the new layout. Nevertheless it is not good programming style to call this function after children have been inserted.

See also orientation and columns.

void QGroupBox::setColumns ( int )

Sets the number of columns in the group box. See the "columns" property for details.

void QGroupBox::setInsideMargin ( int m )

Sets the the width of the blank spacing between each of the items in the group to m pixels.

See also insideSpacing().

void QGroupBox::setInsideSpacing ( int s )

Sets the width of the blank spacing between each of the items in the group to s pixels.

void QGroupBox::setOrientation ( Orientation )

Sets the current orientation of the group box. See the "orientation" property for details.

void QGroupBox::setTitle ( const QString & ) [virtual]

Sets the group box title text. See the "title" property for details.

QString QGroupBox::title () const

Returns the group box title text. See the "title" property for details.


Property Documentation

Alignment alignment

This property holds the alignment of the group box title.

The title is always placed on the upper frame line; however, the horizontal alignment can be specified by the alignment parameter.

The alignment is one of the following flags:

The default alignment is AlignAuto.

Set this property's value with setAlignment() and get this property's value with alignment().

See also Qt::AlignmentFlags.

int columns

This property holds the number of columns in the group box.

Usually it is not a good idea to set this property because it is slow (it does a complete layout). It is better to set the number of columns directly in the constructor.

Set this property's value with setColumns() and get this property's value with columns().

Orientation orientation

This property holds the current orientation of the group box.

Usually it is not a good idea to set this property because it is slow (it does a complete layout). It is better to set the orientation directly in the constructor.

Set this property's value with setOrientation() and get this property's value with orientation().

QString title

This property holds the group box title text.

The group box title text will have a focus-change accelerator if the title contains &, followed by an appropriate letter. This produces "User information" with the U underscored; Alt-U moves the keyboard focus into the group:

      g->setTitle( "&User information" );
  

Set this property's value with setTitle() and get this property's value with title().


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.0-beta1-beta1