|
|||||||||
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
public abstract class QLayout
The QLayout
class is the base class of geometry managers. This is an abstract base class inherited by the concrete classes QBoxLayout
, QGridLayout
, QFormLayout
, and QStackedLayout
.
For users of QLayout
subclasses or of QMainWindow
there is seldom any need to use the basic functions provided by QLayout
, such as setSizeConstraint()
or setMenuBar()
. See Layout Classes for more information.
To make your own layout manager, implement the functions addItem()
, sizeHint()
, setGeometry()
, itemAt()
and takeAt()
. You should also implement minimumSize()
to ensure your layout isn't resized to zero size if there is too little space. To support children whose heights depend on their widths, implement hasHeightForWidth()
and heightForWidth()
. See the Border Layout and Flow Layout examples for more information about implementing custom layout managers.
Geometry management stops when the layout manager is deleted.
QLayoutItem
, Layout Classes, Basic Layouts Example, Border Layout Example, and Flow Layout Example.
Nested Class Summary | |
---|---|
static class |
QLayout.SizeConstraint
The possible values are. |
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 | |
---|---|
QLayout()
Constructs a new child QLayout . |
|
QLayout(QWidget parent)
Constructs a new top-level QLayout , with parent parent. |
Method Summary | |
---|---|
boolean |
activate()
Redoes the layout for parentWidget() if necessary. |
protected void |
addChildLayout(QLayout l)
This function is called from addLayout() or insertLayout() functions in subclasses to add layout l as a sub-layout. |
protected void |
addChildWidget(QWidget w)
This function is called from addWidget() functions in subclasses to add w as a child widget. |
abstract void |
addItem(QLayoutItemInterface arg__1)
Implemented in subclasses to add an item. |
void |
addWidget(QWidget w)
Adds widget w to this layout in a manner specific to the layout. |
Qt.Alignment |
alignment()
Returns the alignment of this item. |
protected QRect |
alignmentRect(QRect arg__1)
Returns the rectangle that should be covered when the geometry of this layout is set to r, provided that this layout supports setAlignment() . |
static QSize |
closestAcceptableSize(QWidget w,
QSize s)
Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is as close as possible to size. |
QRect |
contentsRect()
Returns the layout's geometry() rectangle, but taking into account the contents margins. |
QSizePolicy.ControlTypes |
controlTypes()
Returns the control type(s) for the layout item. |
abstract int |
count()
Must be implemented in subclasses to return the number of items in the layout. |
Qt.Orientations |
expandingDirections()
Returns whether this layout item can make use of more space than sizeHint() . |
QRect |
geometry()
Returns the rectangle covered by this layout item. |
com.trolltech.qt.gui.QContentsMargins |
getContentsMargins()
Returns the contents margins of this QLayout. |
boolean |
hasHeightForWidth()
Returns true if this layout's preferred height depends on its width; otherwise returns false. |
int |
heightForWidth(int arg__1)
Returns the preferred height for this layout item, given the width w. |
int |
indexOf(QWidget arg__1)
Searches for widget widget in this layout (not including child layouts). |
void |
invalidate()
Invalidates any cached information in this layout item. |
boolean |
isEmpty()
Implemented in subclasses to return whether this item is empty, i.e. |
boolean |
isEnabled()
Returns true if the layout is enabled; otherwise returns false. |
abstract QLayoutItemInterface |
itemAt(int index)
Must be implemented in subclasses to return the layout item at index. |
QLayout |
layout()
If this item is a QLayout , it is returned as a QLayout ; otherwise 0 is returned. |
QSize |
maximumSize()
Implemented in subclasses to return the maximum size of this item. |
QWidget |
menuBar()
Returns the menu bar set for this layout, or 0 if no menu bar is set. |
int |
minimumHeightForWidth(int arg__1)
Returns the minimum height this widget needs for the given width, w. |
QSize |
minimumSize()
Implemented in subclasses to return the minimum size of this item. |
QWidget |
parentWidget()
Returns the parent widget of this layout, or 0 if this layout is not installed on any widget. |
void |
removeItem(QLayoutItemInterface arg__1)
Removes the layout item item from the layout. |
void |
removeWidget(QWidget w)
Removes the widget widget from the layout. |
boolean |
setAlignment(QLayout l,
Qt.Alignment alignment)
Sets the alignment for the layout l to alignment and returns true if l is found in this layout (not including child layouts); otherwise returns false. |
boolean |
setAlignment(QLayout l,
Qt.AlignmentFlag[] alignment)
Sets the alignment for the layout l to alignment and returns true if l is found in this layout (not including child layouts); otherwise returns false. |
void |
setAlignment(Qt.Alignment alignment)
Sets the alignment of this item to alignment. |
boolean |
setAlignment(QWidget w,
Qt.Alignment alignment)
Sets the alignment for widget w to alignment and returns true if w is found in this layout (not including child layouts); otherwise returns false. |
boolean |
setAlignment(QWidget w,
Qt.AlignmentFlag[] alignment)
Sets the alignment for widget w to alignment and returns true if w is found in this layout (not including child layouts); otherwise returns false. |
void |
setContentsMargins(int left,
int top,
int right,
int bottom)
Sets the left, top, right, and bottom margins to use around the layout. |
void |
setContentsMargins(com.trolltech.qt.gui.QContentsMargins margins)
Sets the contents margins of this QLayout to margins. |
void |
setEnabled(boolean arg__1)
Enables this layout if enable is true, otherwise disables it. |
void |
setGeometry(QRect arg__1)
Implemented in subclasses to set this item's geometry to r. |
void |
setMargin(int arg__1)
This property holds the width of the outside border of the layout. |
void |
setMenuBar(QWidget w)
Tells the geometry manager to place the menu bar widget at the top of parentWidget() , outside QWidget::contentsMargins(). |
void |
setSizeConstraint(QLayout.SizeConstraint arg__1)
This property holds the resize mode of the layout. |
void |
setWidgetSpacing(int arg__1)
This property holds the spacing between widgets inside the layout. |
QLayout.SizeConstraint |
sizeConstraint()
This property holds the resize mode of the layout. |
abstract QSize |
sizeHint()
Implemented in subclasses to return the preferred size of this item. |
QSpacerItem |
spacerItem()
If this item is a QSpacerItem , it is returned as a QSpacerItem ; otherwise 0 is returned. |
abstract QLayoutItemInterface |
takeAt(int index)
Must be implemented in subclasses to remove the layout item at index from the layout, and return the item. |
void |
update()
Updates the layout for parentWidget() . |
QWidget |
widget()
If this item is a QWidget , it is returned as a QWidget ; otherwise 0 is returned. |
int |
widgetSpacing()
This property holds the spacing between widgets inside the layout. |
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 QLayout()
QLayout
. This layout has to be inserted into another layout before geometry management will work.
public QLayout(QWidget parent)
QLayout
, with parent parent. parent may not be 0. There can be only one top-level layout for a widget. It is returned by QWidget::layout()
.
Method Detail |
---|
public final boolean activate()
parentWidget()
if necessary. You should generally not need to call this because it is automatically called at the most appropriate times. It returns true if the layout was redone.
update()
, and QWidget::updateGeometry()
.
protected final void addChildLayout(QLayout l)
The only scenario in which you need to call it directly is if you implement a custom layout that supports nested layouts.
QBoxLayout::addLayout()
, QBoxLayout::insertLayout()
, and QGridLayout::addLayout()
.
protected final void addChildWidget(QWidget w)
If w is already in a layout, this function will give a warning and remove w from the layout. This function must therefore be called before adding w to the layout's data structure.
public final void addWidget(QWidget w)
addItem()
.
public final Qt.Alignment alignment()
setAlignment()
.
alignment
in interface QLayoutItemInterface
protected final QRect alignmentRect(QRect arg__1)
setAlignment()
. The result is derived from sizeHint()
and expanding(). It is never larger than r.
public final QRect contentsRect()
geometry()
rectangle, but taking into account the contents margins. setContentsMargins()
, and getContentsMargins()
.
public final QSizePolicy.ControlTypes controlTypes()
QWidgetItem
, the control type comes from the widget's size policy; for a QLayoutItem
, the control types is derived from the layout's contents. QSizePolicy::controlType()
.
controlTypes
in interface QLayoutItemInterface
public final boolean isEnabled()
setEnabled()
.
public final QWidget menuBar()
setMenuBar()
.
public final QWidget parentWidget()
If the layout is a sub-layout, this function returns the parent widget of the parent layout.
parent()
.
public final void removeItem(QLayoutItemInterface arg__1)
Notice that item can be a layout (since QLayout
inherits QLayoutItem
).
removeWidget()
, and addItem()
.
public final void removeWidget(QWidget w)
Note: The ownership of widget remains the same as when it was added.
removeItem()
, QWidget::setGeometry()
, and addWidget()
.
public final void setAlignment(Qt.Alignment alignment)
Note: Item alignment is only supported by QLayoutItem
subclasses where it would have a visual effect. Except for QSpacerItem
, which provides blank space for layouts, all public Qt classes that inherit QLayoutItem
support item alignment.
alignment()
.
setAlignment
in interface QLayoutItemInterface
public final boolean setAlignment(QLayout l, Qt.AlignmentFlag[] alignment)
public final boolean setAlignment(QLayout l, Qt.Alignment alignment)
public final boolean setAlignment(QWidget w, Qt.AlignmentFlag[] alignment)
public final boolean setAlignment(QWidget w, Qt.Alignment alignment)
public final void setContentsMargins(int left, int top, int right, int bottom)
By default, QLayout
uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
getContentsMargins()
, QStyle::pixelMetric()
, PM_LayoutLeftMargin
, PM_LayoutTopMargin
, PM_LayoutRightMargin
, and PM_LayoutBottomMargin
.
public final void setEnabled(boolean arg__1)
An enabled layout adjusts dynamically to changes; a disabled layout acts as if it did not exist.
By default all layouts are enabled.
isEnabled()
.
public final void setMargin(int arg__1)
setContentsMargins()
and getContentsMargins()
instead. contentsRect()
, and spacing.
public final void setMenuBar(QWidget w)
parentWidget()
, outside QWidget::contentsMargins(). All child widgets are placed below the bottom edge of the menu bar. menuBar()
.
public final void setSizeConstraint(QLayout.SizeConstraint arg__1)
SetDefaultConstraint
.
public final void setWidgetSpacing(int arg__1)
For QGridLayout
and QFormLayout
, it is possible to set different horizontal and vertical spacings using setHorizontalSpacing()
and setVerticalSpacing()
. In that case, spacing() returns -1.
contentsRect()
, getContentsMargins()
, QStyle::layoutSpacing()
, and QStyle::pixelMetric()
.
public final QLayout.SizeConstraint sizeConstraint()
SetDefaultConstraint
.
public final int widgetSpacing()
For QGridLayout
and QFormLayout
, it is possible to set different horizontal and vertical spacings using setHorizontalSpacing()
and setVerticalSpacing()
. In that case, spacing() returns -1.
contentsRect()
, getContentsMargins()
, QStyle::layoutSpacing()
, and QStyle::pixelMetric()
.
public final void update()
parentWidget()
. You should generally not need to call this because it is automatically called at the most appropriate times.
activate()
, and invalidate()
.
public abstract void addItem(QLayoutItemInterface arg__1)
This function is not usually called in application code. To add a widget to a layout, use the addWidget()
function; to add a child layout, use the addLayout() function provided by the relevant QLayout
subclass.
Note: The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.
addWidget()
, QBoxLayout::addLayout()
, and QGridLayout::addLayout()
.
public abstract int count()
itemAt()
.
public Qt.Orientations expandingDirections()
sizeHint()
. A value of Qt::Vertical
or Qt::Horizontal
means that it wants to grow in only one dimension, whereas Qt::Vertical
| Qt::Horizontal
means that it wants to grow in both dimensions.
expandingDirections
in interface QLayoutItemInterface
public QRect geometry()
setGeometry()
.
geometry
in interface QLayoutItemInterface
public boolean hasHeightForWidth()
Reimplement this function in layout managers that support height for width.
heightForWidth()
, and QWidget::heightForWidth()
.
hasHeightForWidth
in interface QLayoutItemInterface
public int heightForWidth(int arg__1)
The default implementation returns -1, indicating that the preferred height is independent of the width of the item. Using the function hasHeightForWidth()
will typically be much faster than calling this function and testing for -1.
Reimplement this function in layout managers that support height for width. A typical implementation will look like this:
public int heightForWidth(int w) { if (cache_dirty || cached_width != w) { int h = calculateHeightForWidth(w); cached_hfw = h; return h; } return cached_hfw; }Caching is strongly recommended; without it layout will take exponential time.
hasHeightForWidth()
.
heightForWidth
in interface QLayoutItemInterface
public int indexOf(QWidget arg__1)
Returns the index of widget, or -1 if widget is not found.
The default implementation iterates over all items using itemAt()
public void invalidate()
invalidate
in interface QLayoutItemInterface
public boolean isEmpty()
isEmpty
in interface QLayoutItemInterface
public abstract QLayoutItemInterface itemAt(int index)
This function can be used to iterate over a layout. The following code will draw a rectangle for each layout item in the layout structure of the widget.
static void paintLayout(QPainter painter, QLayoutItemInterface item) { QLayout layout = item.layout(); if (layout!=null) { for (int i = 0; i < layout.count(); ++i) paintLayout(painter, layout.itemAt(i)); } painter.drawRect(layout.geometry()); } protected void paintEvent(QPaintEvent event) { QPainter painter = new QPainter(this); if (layout() != null) paintLayout(painter, layout()); }
count()
, and takeAt()
.
public QLayout layout()
QLayout
, it is returned as a QLayout
; otherwise 0 is returned. This function provides type-safe casting.
layout
in interface QLayoutItemInterface
public QSize maximumSize()
maximumSize
in interface QLayoutItemInterface
public int minimumHeightForWidth(int arg__1)
minimumHeightForWidth
in interface QLayoutItemInterface
public QSize minimumSize()
minimumSize
in interface QLayoutItemInterface
public void setGeometry(QRect arg__1)
geometry()
.
setGeometry
in interface QLayoutItemInterface
public abstract QSize sizeHint()
sizeHint
in interface QLayoutItemInterface
public QSpacerItem spacerItem()
QSpacerItem
, it is returned as a QSpacerItem
; otherwise 0 is returned. This function provides type-safe casting.
spacerItem
in interface QLayoutItemInterface
public abstract QLayoutItemInterface takeAt(int index)
The following code fragment shows a safe way to remove all items from a layout:
QLayoutItemInterface child = null; while ((child = layout.takeAt(0)) != null) { //... //delete child; }
itemAt()
, and count()
.
public QWidget widget()
QWidget
, it is returned as a QWidget
; otherwise 0 is returned. This function provides type-safe casting.
widget
in interface QLayoutItemInterface
public static QSize closestAcceptableSize(QWidget w, QSize s)
heightForWidth()
and that is as close as possible to size.
public final com.trolltech.qt.gui.QContentsMargins getContentsMargins()
public final void setContentsMargins(com.trolltech.qt.gui.QContentsMargins margins)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |