|
|||||||||
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.gui.QGraphicsLayout
com.trolltech.qt.gui.QGraphicsLinearLayout
public class QGraphicsLinearLayout
The QGraphicsLinearLayout
class provides a horizontal or vertical layout for managing widgets in Graphics View. The default orientation for a linear layout is Qt::Horizontal
. You can choose a vertical orientation either by calling setOrientation()
, or by passing Qt::Vertical
to QGraphicsLinearLayout
's constructor.
The most common way to use QGraphicsLinearLayout
is to construct an object on the heap with no parent, add widgets and layouts by calling addItem()
, and finally assign the layout to a widget by calling QGraphicsWidget::setLayout()
.
QGraphicsScene scene = new QGraphicsScene(); QGraphicsWidget textEdit = scene.addWidget(new QTextEdit()); QGraphicsWidget pushButton = scene.addWidget(new QPushButton()); QGraphicsLinearLayout layout = new QGraphicsLinearLayout(); layout.addItem(textEdit); layout.addItem(pushButton); QGraphicsWidget form = new QGraphicsWidget(); form.setLayout(layout); scene.addItem(form);You can add widgets, layouts, stretches (
addStretch()
, insertStretch()
or setStretchFactor()
), and gaps (addGap()
and setItemSpacing()
) to a linear layout. The layout takes ownership of the items, with one natural exception: when a layout is assigned to a widget, all widgets inside the layout are automatically reparented to the widget, effectively signing over ownership from the layout to the layout-managed widget. You can access each item in the layout by calling count()
and itemAt()
. Calling removeAt()
or removeItem()
will remove an item from the layout, without destroying it.QGraphicsLinearLayout
respects each item's size hints and size policies, and when the layout contains more space than the items can fill, each item is arranged according to the layout's alignment for that item. You can set an alignment for each item by calling setAlignment()
, and check the alignment for any item by calling alignment()
. By default, items are centered both vertically and horizontally.setSpacing()
, and get the current spacing value by calling spacing()
. If you want to configure individual spacing for your items, you can call setItemSpacing()
.QGraphicsLinearLayout
calculates the distribution of sizes by adding up the stretch factors of all items, and then dividing the available space accordingly. The default stretch factor is 0 for all items; a factor of 0 means the item does not have any defined stretch factor; effectively this is the same as setting the stretch factor to 1. The stretch factor only applies to the available space in the lengthwise direction of the layout (following its orientation). If you want to control both the item's horizontal and vertical stretch, you can use QGraphicsGridLayout
instead.QGraphicsLinearLayout Compared to Other Layouts
QGraphicsLinearLayout
is very similar to QVBoxLayout
and QHBoxLayout
, but in contrast to these classes, it is used to manage QGraphicsWidget
and QGraphicsLayout
instead of QWidget
and QLayout
.
QGraphicsGridLayout
, and QGraphicsWidget
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Constructor Summary | |
---|---|
QGraphicsLinearLayout()
Constructs a QGraphicsLinearLayout instance using Qt::Horizontal orientation. |
|
QGraphicsLinearLayout(QGraphicsLayoutItemInterface parent)
Constructs a QGraphicsLinearLayout instance using Qt::Horizontal orientation. |
|
QGraphicsLinearLayout(Qt.Orientation orientation)
Constructs a QGraphicsLinearLayout instance. |
|
QGraphicsLinearLayout(Qt.Orientation orientation,
QGraphicsLayoutItemInterface parent)
Constructs a QGraphicsLinearLayout instance. |
Method Summary | |
---|---|
void |
addItem(QGraphicsLayoutItemInterface item)
This convenience function is equivalent to calling insertItem (-1, item). |
void |
addStretch()
This convenience function is equivalent to calling insertStretch (-1, stretch). |
void |
addStretch(int stretch)
This convenience function is equivalent to calling insertStretch (-1, stretch). |
Qt.Alignment |
alignment(QGraphicsLayoutItemInterface item)
Returns the alignment for item. |
static QGraphicsLinearLayout |
fromNativePointer(QNativePointer nativePointer)
|
void |
insertItem(int index,
QGraphicsLayoutItemInterface item)
Inserts item into the layout at index, or before any item that is currently at index. |
void |
insertStretch(int index)
Inserts a stretch of stretch at index, or before any item that is currently at index. |
void |
insertStretch(int index,
int stretch)
Inserts a stretch of stretch at index, or before any item that is currently at index. |
double |
itemSpacing(int index)
Returns the spacing after item at index. |
Qt.Orientation |
orientation()
This property holds the orientation of the linear layout. |
void |
removeItem(QGraphicsLayoutItemInterface item)
Removes item from the layout without destroying it. |
void |
setAlignment(QGraphicsLayoutItemInterface item,
Qt.Alignment alignment)
Sets the alignment of item to alignment. |
void |
setAlignment(QGraphicsLayoutItemInterface item,
Qt.AlignmentFlag[] alignment)
Sets the alignment of item to alignment. |
void |
setItemSpacing(int index,
double spacing)
Sets the spacing after item at index to spacing. |
void |
setOrientation(Qt.Orientation orientation)
This property holds the orientation of the linear layout. |
void |
setSpacing(double spacing)
This property holds the layout's default spacing. |
void |
setStretchFactor(QGraphicsLayoutItemInterface item,
int stretch)
Sets the stretch factor for item to stretch. |
double |
spacing()
This property holds the layout's default spacing. |
int |
stretchFactor(QGraphicsLayoutItemInterface item)
Returns the stretch factor for item. |
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 java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QGraphicsLinearLayout()
QGraphicsLinearLayout
instance using Qt::Horizontal
orientation. parent is passed to QGraphicsLayout
's constructor.
public QGraphicsLinearLayout(QGraphicsLayoutItemInterface parent)
QGraphicsLinearLayout
instance using Qt::Horizontal
orientation. parent is passed to QGraphicsLayout
's constructor.
public QGraphicsLinearLayout(Qt.Orientation orientation)
QGraphicsLinearLayout
instance. You can pass the orientation for the layout, either horizontal or vertical, and parent is passed to QGraphicsLayout
's constructor.
public QGraphicsLinearLayout(Qt.Orientation orientation, QGraphicsLayoutItemInterface parent)
QGraphicsLinearLayout
instance. You can pass the orientation for the layout, either horizontal or vertical, and parent is passed to QGraphicsLayout
's constructor.
Method Detail |
---|
public final void addItem(QGraphicsLayoutItemInterface item)
insertItem
(-1, item).
public final void addStretch()
insertStretch
(-1, stretch).
public final void addStretch(int stretch)
insertStretch
(-1, stretch).
public final Qt.Alignment alignment(QGraphicsLayoutItemInterface item)
Qt::AlignCenter
. The alignment decides how the item is positioned within its assigned space in the case where there's more space available in the layout than the widgets can occupy.
setAlignment()
.
public final void insertItem(int index, QGraphicsLayoutItemInterface item)
addItem()
, itemAt()
, insertStretch()
, and setItemSpacing()
.
public final void insertStretch(int index)
addStretch()
, setStretchFactor()
, setItemSpacing()
, and insertItem()
.
public final void insertStretch(int index, int stretch)
addStretch()
, setStretchFactor()
, setItemSpacing()
, and insertItem()
.
public final double itemSpacing(int index)
setItemSpacing()
.
public final Qt.Orientation orientation()
invalidate()
.
public final void removeItem(QGraphicsLayoutItemInterface item)
removeAt()
, and insertItem()
.
public final void setAlignment(QGraphicsLayoutItemInterface item, Qt.AlignmentFlag[] alignment)
alignment()
, and invalidate()
.
public final void setAlignment(QGraphicsLayoutItemInterface item, Qt.Alignment alignment)
alignment()
, and invalidate()
.
public final void setItemSpacing(int index, double spacing)
itemSpacing()
.
public final void setOrientation(Qt.Orientation orientation)
invalidate()
.
public final void setSpacing(double spacing)
setItemSpacing()
, setStretchFactor()
, and QGraphicsGridLayout::setSpacing()
.
public final void setStretchFactor(QGraphicsLayoutItemInterface item, int stretch)
Setting stretch to 0 removes the stretch factor from the item, and is effectively equivalent to setting stretch to 1.
stretchFactor()
.
public final double spacing()
setItemSpacing()
, setStretchFactor()
, and QGraphicsGridLayout::setSpacing()
.
public final int stretchFactor(QGraphicsLayoutItemInterface item)
setStretchFactor()
.
public static QGraphicsLinearLayout fromNativePointer(QNativePointer nativePointer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |