|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QLayout
com.trolltech.qt.gui.QGridLayout
public class QGridLayout
The QGridLayout class lays out widgets in a grid. QGridLayout takes the space made available to it (by its parent layout or by the parentWidget()
), divides it up into rows and columns, and puts each widget it manages into the correct cell.
Columns and rows behave identically; we will discuss columns, but there are equivalent functions for rows.
Each column has a minimum width and a stretch factor. The minimum width is the greatest of that set using setColumnMinimumWidth()
and the minimum width of each widget in that column. The stretch factor is set using setColumnStretch()
and determines how much of the available space the column will get over and above its necessary minimum.
Normally, each managed widget or layout is put into a cell of its own using addWidget()
. It is also possible for a widget to occupy multiple cells using the row and column spanning overloads of addItem()
and addWidget()
. If you do this, QGridLayout will guess how to distribute the size over the columns/rows (based on the stretch factors).
To remove a widget from a layout, call removeWidget()
. Calling QWidget::hide()
on a widget also effectively removes the widget from the layout until QWidget::show()
is called.
This illustration shows a fragment of a dialog with a five-column, three-row grid (the grid is shown overlaid in magenta):
QLabel
, a QLineEdit
, and a QListBox. Columns 1 and 3 are placeholders made with setColumnMinimumWidth()
. Row 0 consists of three QLabel
objects, row 1 of three QLineEdit
objects and row 2 of three QListBox objects. We used placeholder columns (1 and 3) to get the right amount of space between the columns. Note that the columns and rows are not equally wide or tall. If you want two columns to have the same width, you must set their minimum widths and stretch factors to be the same yourself. You do this using setColumnMinimumWidth()
and setColumnStretch()
.
If the QGridLayout is not the top-level layout (i.e. does not manage all of the widget's area and children), you must add it to its parent layout when you create it, but before you do anything with it. The normal way to add a layout is by calling addLayout()
on the parent layout.
Once you have added your layout you can start putting widgets and other layouts into the cells of your grid layout using addWidget()
, addItem()
, and addLayout()
.
QGridLayout also includes two margin widths: the margin() and the spacing()
. The margin is the width of the reserved space along each of the QGridLayout's four sides. The spacing is the width of the automatically allocated spacing between neighboring boxes.
The default margin() and spacing()
values are provided by the style. The default margin Qt styles specify is 9 for child widgets and 11 for windows. The spacing defaults to the same as the margin width for a top-level layout, or to the same as the parent layout.
QBoxLayout
, QStackedLayout
, Layout Classes, and Basic Layouts Example.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QLayout |
---|
QLayout.SizeConstraint |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QGridLayout()
Constructs a new grid layout. |
|
QGridLayout(QWidget parent)
Constructs a new QGridLayout with parent widget, parent. |
Method Summary | |
---|---|
void |
addItem(QLayoutItemInterface item,
int row,
int column)
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it according to alignment. |
void |
addItem(QLayoutItemInterface item,
int row,
int column,
int rowSpan)
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it according to alignment. |
void |
addItem(QLayoutItemInterface item,
int row,
int column,
int rowSpan,
int columnSpan)
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it according to alignment. |
void |
addItem(QLayoutItemInterface item,
int row,
int column,
int rowSpan,
int columnSpan,
Qt.Alignment arg__6)
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it according to alignment. |
void |
addItem(QLayoutItemInterface item,
int row,
int column,
int rowSpan,
int columnSpan,
Qt.AlignmentFlag[] arg__6)
|
void |
addLayout(QLayout arg__1,
int row,
int column)
Places the layout at position (row, column) in the grid. |
void |
addLayout(QLayout arg__1,
int row,
int column,
int rowSpan,
int columnSpan)
This version adds the layout layout to the cell grid, spanning multiple rows/columns. |
void |
addLayout(QLayout arg__1,
int row,
int column,
int rowSpan,
int columnSpan,
Qt.Alignment arg__6)
This version adds the layout layout to the cell grid, spanning multiple rows/columns. |
void |
addLayout(QLayout arg__1,
int row,
int column,
int rowSpan,
int columnSpan,
Qt.AlignmentFlag[] arg__6)
|
void |
addLayout(QLayout arg__1,
int row,
int column,
Qt.Alignment arg__4)
Places the layout at position (row, column) in the grid. |
void |
addLayout(QLayout arg__1,
int row,
int column,
Qt.AlignmentFlag[] arg__4)
|
void |
addWidget(QWidget arg__1,
int row,
int column)
Adds the given widget to the cell grid at row, column. |
void |
addWidget(QWidget arg__1,
int row,
int column,
int rowSpan,
int columnSpan)
This version adds the given widget to the cell grid, spanning multiple rows/columns. |
void |
addWidget(QWidget arg__1,
int row,
int column,
int rowSpan,
int columnSpan,
Qt.Alignment arg__6)
This version adds the given widget to the cell grid, spanning multiple rows/columns. |
void |
addWidget(QWidget arg__1,
int row,
int column,
int rowSpan,
int columnSpan,
Qt.AlignmentFlag[] arg__6)
|
void |
addWidget(QWidget arg__1,
int row,
int column,
Qt.Alignment arg__4)
Adds the given widget to the cell grid at row, column. |
void |
addWidget(QWidget arg__1,
int row,
int column,
Qt.AlignmentFlag[] arg__4)
|
QRect |
cellRect(int row,
int column)
Returns the geometry of the cell with row row and column column in the grid. |
int |
columnCount()
Returns the number of columns in this grid. |
int |
columnMinimumWidth(int column)
Returns the column spacing for column column. |
int |
columnStretch(int column)
Returns the stretch factor for column column. |
com.trolltech.qt.gui.QTableArea |
getItemPosition(int index)
Returns the position information of the item with the given index. |
int |
horizontalSpacing()
This property holds the spacing between widgets that are laid out side by side. |
QLayoutItemInterface |
itemAtPosition(int row,
int column)
Returns the layout item that occupies cell (row, column), or 0 if the cell is empty. |
Qt.Corner |
originCorner()
Returns the corner that's used for the grid's origin, i. |
int |
rowCount()
Returns the number of rows in this grid. |
int |
rowMinimumHeight(int row)
Returns the minimum width set for row row. |
int |
rowStretch(int row)
Returns the stretch factor for row row. |
void |
setColumnMinimumWidth(int column,
int minSize)
Sets the minimum width of column column to minSize pixels. |
void |
setColumnStretch(int column,
int stretch)
Sets the stretch factor of column column to stretch. |
void |
setHorizontalSpacing(int spacing)
This property holds the spacing between widgets that are laid out side by side. |
void |
setOriginCorner(Qt.Corner arg__1)
Sets the grid's origin corner, i. |
void |
setRowMinimumHeight(int row,
int minSize)
Sets the minimum height of row row to minSize pixels. |
void |
setRowStretch(int row,
int stretch)
Sets the stretch factor of row row to stretch. |
void |
setSpacing(int spacing)
This function sets both the vertical and horizontal spacing to spacing. |
void |
setVerticalSpacing(int spacing)
This property holds the spacing between widgets that are laid out on top of each other. |
int |
spacing()
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwise it return -1. |
int |
verticalSpacing()
This property holds the spacing between widgets that are laid out on top of each other. |
Methods inherited from class com.trolltech.qt.gui.QLayout |
---|
activate, addChildLayout, addChildWidget, addItem, addWidget, alignment, alignmentRect, closestAcceptableSize, contentsRect, controlTypes, count, expandingDirections, geometry, getContentsMargins, hasHeightForWidth, heightForWidth, indexOf, invalidate, isEmpty, isEnabled, itemAt, layout, maximumSize, menuBar, minimumHeightForWidth, minimumSize, parentWidget, removeItem, removeWidget, setAlignment, setAlignment, setAlignment, setAlignment, setAlignment, setContentsMargins, setContentsMargins, setEnabled, setGeometry, setMargin, setMenuBar, setSizeConstraint, setWidgetSpacing, sizeConstraint, sizeHint, spacerItem, takeAt, update, widget, widgetSpacing |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QGridLayout()
You must insert this grid into another layout. You can insert widgets and layouts into this layout at any time, but laying out will not be performed before this is inserted into another layout.
public QGridLayout(QWidget parent)
Method Detail |
---|
public final void addItem(QLayoutItemInterface item, int row, int column, int rowSpan, int columnSpan, Qt.AlignmentFlag[] arg__6)
public final void addItem(QLayoutItemInterface item, int row, int column, int rowSpan, int columnSpan)
Warning: Do not use this function to add child layouts or child widget items. Use addLayout()
or addWidget()
instead.
public final void addItem(QLayoutItemInterface item, int row, int column, int rowSpan)
Warning: Do not use this function to add child layouts or child widget items. Use addLayout()
or addWidget()
instead.
public final void addItem(QLayoutItemInterface item, int row, int column)
Warning: Do not use this function to add child layouts or child widget items. Use addLayout()
or addWidget()
instead.
public final void addItem(QLayoutItemInterface item, int row, int column, int rowSpan, int columnSpan, Qt.Alignment arg__6)
Warning: Do not use this function to add child layouts or child widget items. Use addLayout()
or addWidget()
instead.
public final void addLayout(QLayout arg__1, int row, int column, Qt.AlignmentFlag[] arg__4)
public final void addLayout(QLayout arg__1, int row, int column)
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
A non-zero alignment indicates that the layout should not grow to fill the available space but should be sized according to sizeHint()
.
layout becomes a child of the grid layout.
public final void addLayout(QLayout arg__1, int row, int column, Qt.Alignment arg__4)
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
A non-zero alignment indicates that the layout should not grow to fill the available space but should be sized according to sizeHint()
.
layout becomes a child of the grid layout.
public final void addLayout(QLayout arg__1, int row, int column, int rowSpan, int columnSpan, Qt.AlignmentFlag[] arg__6)
public final void addLayout(QLayout arg__1, int row, int column, int rowSpan, int columnSpan)
If rowSpan and/or columnSpan is -1, then the layout will extend to the bottom and/or right edge, respectively.
public final void addLayout(QLayout arg__1, int row, int column, int rowSpan, int columnSpan, Qt.Alignment arg__6)
If rowSpan and/or columnSpan is -1, then the layout will extend to the bottom and/or right edge, respectively.
public final void addWidget(QWidget arg__1, int row, int column, Qt.AlignmentFlag[] arg__4)
public final void addWidget(QWidget arg__1, int row, int column)
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
public final void addWidget(QWidget arg__1, int row, int column, Qt.Alignment arg__4)
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
public final void addWidget(QWidget arg__1, int row, int column, int rowSpan, int columnSpan, Qt.AlignmentFlag[] arg__6)
public final void addWidget(QWidget arg__1, int row, int column, int rowSpan, int columnSpan)
If rowSpan and/or columnSpan is -1, then the widget will extend to the bottom and/or right edge, respectively.
public final void addWidget(QWidget arg__1, int row, int column, int rowSpan, int columnSpan, Qt.Alignment arg__6)
If rowSpan and/or columnSpan is -1, then the widget will extend to the bottom and/or right edge, respectively.
public final QRect cellRect(int row, int column)
Warning: in the current version of Qt this function does not return valid results until setGeometry()
has been called, i.e. after the parentWidget()
is visible.
public final int columnCount()
public final int columnMinimumWidth(int column)
setColumnMinimumWidth()
.
public final int columnStretch(int column)
setColumnStretch()
.
public final int horizontalSpacing()
verticalSpacing
, QStyle::pixelMetric()
, and PM_LayoutHorizontalSpacing
.
public final QLayoutItemInterface itemAtPosition(int row, int column)
getItemPosition()
, and indexOf()
.
public final Qt.Corner originCorner()
setOriginCorner()
.
public final int rowCount()
public final int rowMinimumHeight(int row)
setRowMinimumHeight()
.
public final int rowStretch(int row)
setRowStretch()
.
public final void setColumnMinimumWidth(int column, int minSize)
columnMinimumWidth()
, and setRowMinimumHeight()
.
public final void setColumnStretch(int column, int stretch)
The stretch factor is relative to the other columns in this grid. Columns with a higher stretch factor take more of the available space.
The default stretch factor is 0. If the stretch factor is 0 and no other column in this table can grow at all, the column may still grow.
An alternative approach is to add spacing using addItem()
with a QSpacerItem
.
columnStretch()
, and setRowStretch()
.
public final void setHorizontalSpacing(int spacing)
verticalSpacing
, QStyle::pixelMetric()
, and PM_LayoutHorizontalSpacing
.
public final void setOriginCorner(Qt.Corner arg__1)
originCorner()
.
public final void setRowMinimumHeight(int row, int minSize)
rowMinimumHeight()
, and setColumnMinimumWidth()
.
public final void setRowStretch(int row, int stretch)
The stretch factor is relative to the other rows in this grid. Rows with a higher stretch factor take more of the available space.
The default stretch factor is 0. If the stretch factor is 0 and no other row in this table can grow at all, the row may still grow.
rowStretch()
, setRowMinimumHeight()
, and setColumnStretch()
.
public final void setSpacing(int spacing)
spacing()
, setVerticalSpacing()
, and setHorizontalSpacing()
.
public final void setVerticalSpacing(int spacing)
horizontalSpacing
, QStyle::pixelMetric()
, and PM_LayoutHorizontalSpacing
.
public final int spacing()
setSpacing()
, verticalSpacing()
, and horizontalSpacing()
.
public final int verticalSpacing()
horizontalSpacing
, QStyle::pixelMetric()
, and PM_LayoutHorizontalSpacing
.
public final com.trolltech.qt.gui.QTableArea getItemPosition(int index)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |