|
|||||||||
| 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.QGraphicsLayoutItem
public abstract class QGraphicsLayoutItem
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts. QGraphicsLayoutItem is an abstract class that defines a set of virtual functions describing sizes, size policies, and size hints for any object arranged by QGraphicsLayout. The API contains functions relevant for both the item itself and for the user of the item as most of QGraphicsLayoutItem's functions are also part of the subclass' public API.
In most cases, existing layout-aware classes such as QGraphicsWidget and QGraphicsLayout already provide the functionality you require. However, subclassing these classes will enable you to create both graphical elements that work well with layouts (QGraphicsWidget) or custom layouts (QGraphicsLayout).Subclassing QGraphicsLayoutItem
If you create a subclass of QGraphicsLayoutItem and reimplement its virtual functions, you will enable the layout to resize and position your item along with other QGraphicsLayoutItems including QGraphicsWidget and QGraphicsLayout.
You can start by reimplementing important functions: the protected sizeHint() function, as well as the public setGeometry() function. If you want your items to be aware of immediate geometry changes, you can also reimplement updateGeometry().
The geometry, size hint, and size policy affect the item's size and position. Calling setGeometry() will always resize and reposition the item immediately. Normally, this function is called by QGraphicsLayout after the layout has been activated, but it can also be called by the item's user at any time.
The sizeHint() function returns the item' minimum, preferred and maximum size hints. You can override these properties by calling setMinimumSize(), setPreferredSize() or setMaximumSize(). You can also use functions such as setMinimumWidth() or setMaximumHeight() to set only the width or height component if desired.
The effectiveSizeHint() function, on the other hand, returns a size hint for any given Qt::SizeHint , and guarantees that the returned size is bound to the minimum and maximum sizes and size hints. You can set the item's vertical and horizontal size policy by calling setSizePolicy(). The sizePolicy property is used by the layout system to describe how this item prefers to grow or shrink.Nesting QGraphicsLayoutItems
QGraphicsLayoutItems can be nested within other QGraphicsLayoutItems, similar to layouts that can contain sublayouts. This is done either by passing a QGraphicsLayoutItem pointer to QGraphicsLayoutItem's protected constructor, or by calling setParentLayoutItem(). The parentLayoutItem() function returns a pointer to the item's layoutItem parent. If the item's parent is 0 or if the the parent does not inherit from QGraphicsItem, the parentLayoutItem() function then returns 0. isLayout() returns true if the QGraphicsLayoutItem subclass is itself a layout, or false otherwise.
Qt uses QGraphicsLayoutItem to provide layout functionality in the The Graphics View Framework, but in the future its use may spread throughout Qt itself.
QGraphicsWidget, QGraphicsLayout, QGraphicsLinearLayout, and QGraphicsGridLayout.
| 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 | |
|---|---|
QGraphicsLayoutItem()
Constructs the QGraphicsLayoutItem object. |
|
QGraphicsLayoutItem(QGraphicsLayoutItemInterface parent)
Constructs the QGraphicsLayoutItem object. |
|
QGraphicsLayoutItem(QGraphicsLayoutItemInterface parent,
boolean isLayout)
Constructs the QGraphicsLayoutItem object. |
|
| Method Summary | |
|---|---|
QRectF |
contentsRect()
Returns the contents rect in local coordinates. |
QSizeF |
effectiveSizeHint(Qt.SizeHint which)
Returns the effective size hint for this QGraphicsLayoutItem. |
QSizeF |
effectiveSizeHint(Qt.SizeHint which,
QSizeF constraint)
Returns the effective size hint for this QGraphicsLayoutItem. |
static QGraphicsLayoutItem |
fromNativePointer(QNativePointer nativePointer)
|
QRectF |
geometry()
Returns the item's geometry (e.g., position and size) as a QRectF. |
QMarginsF |
getContentsMargins()
This virtual function provides the left, top, right and bottom contents margins for this QGraphicsLayoutItem. |
boolean |
isLayout()
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other QGraphicsLayoutItem objects); otherwise returns false. |
double |
maximumHeight()
Returns the maximum height. |
QSizeF |
maximumSize()
Returns the maximum size. |
double |
maximumWidth()
Returns the maximum width. |
double |
minimumHeight()
Returns the minimum height. |
QSizeF |
minimumSize()
Returns the minimum size. |
double |
minimumWidth()
Returns the minimum width. |
QGraphicsLayoutItemInterface |
parentLayoutItem()
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with QObject-derived classes). |
double |
preferredHeight()
Returns the preferred height. |
QSizeF |
preferredSize()
Returns the preferred size. |
double |
preferredWidth()
Returns the preferred width. |
void |
setGeometry(QRectF rect)
This pure virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordinates (e.g., the top-left corner of rect is equivalent to the item's position in parent coordinates). |
void |
setMaximumHeight(double height)
Sets the maximum height to height. |
void |
setMaximumSize(double w,
double h)
This convenience function is equivalent to calling setMaximumSize( QSizeF(w, h)). |
void |
setMaximumSize(QSizeF size)
Sets the maximum size to size. |
void |
setMaximumWidth(double width)
Sets the maximum width to width. |
void |
setMinimumHeight(double height)
Sets the minimum height to height. |
void |
setMinimumSize(double w,
double h)
This convenience function is equivalent to calling setMinimumSize( QSizeF(w, h)). |
void |
setMinimumSize(QSizeF size)
Sets the minimum size to size. |
void |
setMinimumWidth(double width)
Sets the minimum width to width. |
void |
setParentLayoutItem(QGraphicsLayoutItemInterface parent)
Sets the parent of this QGraphicsLayoutItem to parent. |
void |
setPreferredHeight(double height)
Sets the preferred height to height. |
void |
setPreferredSize(double w,
double h)
This convenience function is equivalent to calling setPreferredSize( QSizeF(w, h)). |
void |
setPreferredSize(QSizeF size)
Sets the preferred size to size. |
void |
setPreferredWidth(double width)
Sets the preferred width to width. |
void |
setSizePolicy(QSizePolicy.Policy hPolicy,
QSizePolicy.Policy vPolicy)
This function is equivalent to calling setSizePolicy( QSizePolicy(hPolicy, vPolicy, controlType)). |
void |
setSizePolicy(QSizePolicy.Policy hPolicy,
QSizePolicy.Policy vPolicy,
QSizePolicy.ControlType controlType)
This function is equivalent to calling setSizePolicy( QSizePolicy(hPolicy, vPolicy, controlType)). |
void |
setSizePolicy(QSizePolicy policy)
Sets the size policy to policy. |
QSizeF |
sizeHint(Qt.SizeHint which)
This pure virtual function returns the size hint for which of the QGraphicsLayoutItem, using the width or height of constraint to constrain the output. |
abstract QSizeF |
sizeHint(Qt.SizeHint which,
QSizeF constraint)
This pure virtual function returns the size hint for which of the QGraphicsLayoutItem, using the width or height of constraint to constrain the output. |
QSizePolicy |
sizePolicy()
Returns the current size policy. |
void |
updateGeometry()
This virtual function discards any cached size hint information. |
| 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 QGraphicsLayoutItem(QGraphicsLayoutItemInterface parent)
QGraphicsLayoutItem object. parent becomes the object's parent. If isLayout is true the item is a layout, otherwise isLayout is false.
public QGraphicsLayoutItem()
QGraphicsLayoutItem object. parent becomes the object's parent. If isLayout is true the item is a layout, otherwise isLayout is false.
public QGraphicsLayoutItem(QGraphicsLayoutItemInterface parent,
boolean isLayout)
QGraphicsLayoutItem object. parent becomes the object's parent. If isLayout is true the item is a layout, otherwise isLayout is false.
| Method Detail |
|---|
public final QRectF contentsRect()
The contents rect defines the subrectangle used by an associated layout when arranging subitems. This function is a convenience function that adjusts the item's geometry() by its contents margins. Note that getContentsMargins() is a virtual function that you can reimplement to return the item's contents margins.
getContentsMargins(), and geometry().
contentsRect in interface QGraphicsLayoutItemInterfacepublic final QSizeF effectiveSizeHint(Qt.SizeHint which)
QGraphicsLayoutItem. which is the size hint in question. constraint is an optional argument that defines a special constrain when calculating the effective size hint. By default, constraint is QSizeF(-1, -1), which means there is no constraint to the size hint.
If you want to specify the widget's size hint for a given width or height, you can provide the fixed dimension in constraint. This is useful for widgets that can grow only either vertically or horizontally, and need to set either their width or their height to a special value.
For example, a text paragraph item fit into a column width of 200 may grow vertically. You can pass QSizeF(200, -1) as a constraint to get a suitable minimum, preferred and maximum height).
You can adjust the effective size hint by reimplementing sizeHint() in a QGraphicsLayoutItem subclass, or by calling one of the following functions: setMinimumSize(), setPreferredSize, or setMaximumSize() (or a combination of both).
This function caches each of the size hints and guarantees that sizeHint() will be called only once for each value of which - unless constraint is not specified and updateGeometry() has been called.
sizeHint().
public final QSizeF effectiveSizeHint(Qt.SizeHint which,
QSizeF constraint)
QGraphicsLayoutItem. which is the size hint in question. constraint is an optional argument that defines a special constrain when calculating the effective size hint. By default, constraint is QSizeF(-1, -1), which means there is no constraint to the size hint.
If you want to specify the widget's size hint for a given width or height, you can provide the fixed dimension in constraint. This is useful for widgets that can grow only either vertically or horizontally, and need to set either their width or their height to a special value.
For example, a text paragraph item fit into a column width of 200 may grow vertically. You can pass QSizeF(200, -1) as a constraint to get a suitable minimum, preferred and maximum height).
You can adjust the effective size hint by reimplementing sizeHint() in a QGraphicsLayoutItem subclass, or by calling one of the following functions: setMinimumSize(), setPreferredSize, or setMaximumSize() (or a combination of both).
This function caches each of the size hints and guarantees that sizeHint() will be called only once for each value of which - unless constraint is not specified and updateGeometry() has been called.
sizeHint().
effectiveSizeHint in interface QGraphicsLayoutItemInterfacepublic final QRectF geometry()
QRectF. This function is equivalent to QRectF(pos(), size()). setGeometry().
geometry in interface QGraphicsLayoutItemInterfacepublic final boolean isLayout()
QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other QGraphicsLayoutItem objects); otherwise returns false. QGraphicsLayout.
isLayout in interface QGraphicsLayoutItemInterfacepublic final double maximumHeight()
setMaximumHeight(), setMaximumSize(), and maximumSize().
maximumHeight in interface QGraphicsLayoutItemInterfacepublic final QSizeF maximumSize()
setMaximumSize(), minimumSize(), preferredSize(), Qt::MaximumSize , and sizeHint().
maximumSize in interface QGraphicsLayoutItemInterfacepublic final double maximumWidth()
setMaximumWidth(), setMaximumSize(), and maximumSize().
maximumWidth in interface QGraphicsLayoutItemInterfacepublic final double minimumHeight()
setMinimumHeight(), setMinimumSize(), and minimumSize().
minimumHeight in interface QGraphicsLayoutItemInterfacepublic final QSizeF minimumSize()
setMinimumSize(), preferredSize(), maximumSize(), Qt::MinimumSize , and sizeHint().
minimumSize in interface QGraphicsLayoutItemInterfacepublic final double minimumWidth()
setMinimumWidth(), setMinimumSize(), and minimumSize().
minimumWidth in interface QGraphicsLayoutItemInterfacepublic final QGraphicsLayoutItemInterface parentLayoutItem()
QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with QObject-derived classes). setParentLayoutItem().
parentLayoutItem in interface QGraphicsLayoutItemInterfacepublic final double preferredHeight()
setPreferredHeight(), setPreferredSize(), and preferredSize().
preferredHeight in interface QGraphicsLayoutItemInterfacepublic final QSizeF preferredSize()
setPreferredSize(), minimumSize(), maximumSize(), Qt::PreferredSize , and sizeHint().
preferredSize in interface QGraphicsLayoutItemInterfacepublic final double preferredWidth()
setPreferredWidth(), setPreferredSize(), and preferredSize().
preferredWidth in interface QGraphicsLayoutItemInterfacepublic final void setMaximumHeight(double height)
maximumHeight(), setMaximumSize(), and maximumSize().
setMaximumHeight in interface QGraphicsLayoutItemInterfacepublic final void setMaximumSize(QSizeF size)
sizeHint() for Qt::MaximumSize and ensures that effectiveSizeHint() will never return a size larger than size. In order to unset the maximum size, use an invalid size. maximumSize(), minimumSize(), preferredSize(), Qt::MaximumSize , and sizeHint().
setMaximumSize in interface QGraphicsLayoutItemInterface
public final void setMaximumSize(double w,
double h)
QSizeF(w, h)). maximumSize(), setMinimumSize(), setPreferredSize(), and sizeHint().
setMaximumSize in interface QGraphicsLayoutItemInterfacepublic final void setMaximumWidth(double width)
maximumWidth(), setMaximumSize(), and maximumSize().
setMaximumWidth in interface QGraphicsLayoutItemInterfacepublic final void setMinimumHeight(double height)
minimumHeight(), setMinimumSize(), and minimumSize().
setMinimumHeight in interface QGraphicsLayoutItemInterfacepublic final void setMinimumSize(QSizeF size)
sizeHint() for Qt::MinimumSize and ensures that effectiveSizeHint() will never return a size smaller than size. In order to unset the minimum size, use an invalid size. minimumSize(), maximumSize(), preferredSize(), Qt::MinimumSize , sizeHint(), setMinimumWidth(), and setMinimumHeight().
setMinimumSize in interface QGraphicsLayoutItemInterface
public final void setMinimumSize(double w,
double h)
QSizeF(w, h)). minimumSize(), setMaximumSize(), setPreferredSize(), and sizeHint().
setMinimumSize in interface QGraphicsLayoutItemInterfacepublic final void setMinimumWidth(double width)
minimumWidth(), setMinimumSize(), and minimumSize().
setMinimumWidth in interface QGraphicsLayoutItemInterfacepublic final void setParentLayoutItem(QGraphicsLayoutItemInterface parent)
QGraphicsLayoutItem to parent. parentLayoutItem().
setParentLayoutItem in interface QGraphicsLayoutItemInterfacepublic final void setPreferredHeight(double height)
preferredHeight(), preferredWidth(), setPreferredSize(), and preferredSize().
setPreferredHeight in interface QGraphicsLayoutItemInterfacepublic final void setPreferredSize(QSizeF size)
sizeHint() for Qt::PreferredSize and provides the default value for effectiveSizeHint(). In order to unset the preferred size, use an invalid size. preferredSize(), minimumSize(), maximumSize(), Qt::PreferredSize , and sizeHint().
setPreferredSize in interface QGraphicsLayoutItemInterface
public final void setPreferredSize(double w,
double h)
QSizeF(w, h)). preferredSize(), setMaximumSize(), setMinimumSize(), and sizeHint().
setPreferredSize in interface QGraphicsLayoutItemInterfacepublic final void setPreferredWidth(double width)
preferredWidth(), preferredHeight(), setPreferredSize(), and preferredSize().
setPreferredWidth in interface QGraphicsLayoutItemInterface
public final void setSizePolicy(QSizePolicy.Policy hPolicy,
QSizePolicy.Policy vPolicy)
QSizePolicy(hPolicy, vPolicy, controlType)). sizePolicy(), and QWidget::sizePolicy().
public final void setSizePolicy(QSizePolicy.Policy hPolicy,
QSizePolicy.Policy vPolicy,
QSizePolicy.ControlType controlType)
QSizePolicy(hPolicy, vPolicy, controlType)). sizePolicy(), and QWidget::sizePolicy().
setSizePolicy in interface QGraphicsLayoutItemInterfacepublic final void setSizePolicy(QSizePolicy policy)
QGraphicsLayoutItem's default size policy is (QSizePolicy::Fixed , QSizePolicy::Fixed , QSizePolicy::DefaultType ), but it is common for subclasses to change the default. For example, QGraphicsWidget defaults to (QSizePolicy::Preferred , QSizePolicy::Preferred , QSizePolicy::DefaultType ).
sizePolicy(), and QWidget::sizePolicy().
setSizePolicy in interface QGraphicsLayoutItemInterfacepublic final QSizePolicy sizePolicy()
setSizePolicy(), and QWidget::sizePolicy().
sizePolicy in interface QGraphicsLayoutItemInterfacepublic void setGeometry(QRectF rect)
QGraphicsLayoutItem to rect, which is in parent coordinates (e.g., the top-left corner of rect is equivalent to the item's position in parent coordinates). Reimplement this function in a subclass of QGraphicsLayoutItem to enable your item to receive geometry updates.
If rect is outside of the bounds of minimumSize and maximumSize, it will be adjusted to its closest size so that it is within the legal bounds.
geometry().
setGeometry in interface QGraphicsLayoutItemInterfacepublic final QSizeF sizeHint(Qt.SizeHint which)
QGraphicsLayoutItem, using the width or height of constraint to constrain the output. Reimplement this function in a subclass of QGraphicsLayoutItem to provide the necessary size hints for your items.
effectiveSizeHint().
public abstract QSizeF sizeHint(Qt.SizeHint which,
QSizeF constraint)
QGraphicsLayoutItem, using the width or height of constraint to constrain the output. Reimplement this function in a subclass of QGraphicsLayoutItem to provide the necessary size hints for your items.
effectiveSizeHint().
sizeHint in interface QGraphicsLayoutItemInterfacepublic void updateGeometry()
sizeHint() function. Subclasses must always call the base implementation when reimplementing this function. effectiveSizeHint().
updateGeometry in interface QGraphicsLayoutItemInterfacepublic static QGraphicsLayoutItem fromNativePointer(QNativePointer nativePointer)
public final QMarginsF getContentsMargins()
QGraphicsLayoutItem. The default implementation assumes all contents margins are 0. The parameters point to values stored in qreals. If any of the pointers is 0, that value will not be updated. QGraphicsWidget::setContentsMargins().
getContentsMargins in interface QGraphicsLayoutItemInterface
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||