com.trolltech.qt.gui
Class QLayoutItem

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.gui.QLayoutItem
All Implemented Interfaces:
QLayoutItemInterface, QtJambiInterface

public abstract class QLayoutItem
extends QtJambiObject
implements QLayoutItemInterface

The QLayoutItem class provides an abstract item that a QLayout manipulates.

This is used by custom layouts.

Pure virtual functions are provided to return information about the layout, including, sizeHint, minimumSize, maximumSize and expanding().

The layout's geometry can be set and retrieved with setGeometry and geometry, and its alignment with setAlignment and alignment.

isEmpty returns whether the layout item is empty. If the concrete item is a QWidget, it can be retrieved using widget. Similarly for layout and spacerItem.

Some layouts have width and height interdependencies. These can be expressed using hasHeightForWidth, heightForWidth, and minimumHeightForWidth. For more explanation see the Qt Quarterly article Trading Height for Width.

See Also:
QLayout

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QLayoutItem()
          Equivalent to QLayoutItem(0).
QLayoutItem(Qt.Alignment alignment)
          Constructs a layout item with an alignment.
 
Method Summary
protected  Qt.Alignment align()
          Returns the alignment of this QlayoutItem.
 Qt.Alignment alignment()
          Returns the alignment of this item.
 QSizePolicy.ControlTypes controlTypes()
          Returns the control type(s) for the layout item.
abstract  Qt.Orientations expandingDirections()
          Returns whether this layout item can make use of more space than sizeHint.
static QLayoutItem fromNativePointer(QNativePointer nativePointer)
          This function returns the QLayoutItem instance pointed to by nativePointer
abstract  QRect geometry()
          Returns the rectangle covered by this layout item.
 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 arg__1.
 void invalidate()
          Invalidates any cached information in this layout item.
abstract  boolean isEmpty()
          Implemented in subclasses to return whether this item is empty, i.e. whether it contains any widgets.
 QLayout layout()
          If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
abstract  QSize maximumSize()
          Implemented in subclasses to return the maximum size of this item.
 int minimumHeightForWidth(int arg__1)
          Returns the minimum height this widget needs for the given width, arg__1.
abstract  QSize minimumSize()
          Implemented in subclasses to return the minimum size of this item.
protected  void setAlign(Qt.Alignment align)
          Sets the alignment of this item to align.
protected  void setAlign(Qt.AlignmentFlag... align)
          Sets the alignment of this item to align.
 void setAlignment(Qt.Alignment a)
          Sets the alignment of this item to a.
 void setAlignment(Qt.AlignmentFlag... a)
          Sets the alignment of this item to a.
abstract  void setGeometry(QRect arg__1)
          Implemented in subclasses to set this item's geometry to arg__1.
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.
 QWidget widget()
          If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, 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, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QLayoutItem

public QLayoutItem()

Equivalent to QLayoutItem(0).


QLayoutItem

public QLayoutItem(Qt.Alignment alignment)

Constructs a layout item with an alignment. Not all subclasses support alignment.

Method Detail

alignment

public final Qt.Alignment alignment()

Returns the alignment of this item.

Specified by:
alignment in interface QLayoutItemInterface
See Also:
setAlignment

controlTypes

public final QSizePolicy.ControlTypes controlTypes()

Returns the control type(s) for the layout item. For a QWidgetItem, the control type comes from the widget's size policy; for a QLayoutItem, the control types is derived from the layout's contents.

Specified by:
controlTypes in interface QLayoutItemInterface
See Also:
QSizePolicy::controlType

setAlignment

public final void setAlignment(Qt.AlignmentFlag... a)

Sets the alignment of this item to a.

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.

See Also:
alignment

setAlignment

public final void setAlignment(Qt.Alignment a)

Sets the alignment of this item to a.

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.

Specified by:
setAlignment in interface QLayoutItemInterface
See Also:
alignment

expandingDirections

public abstract Qt.Orientations expandingDirections()

Returns whether this layout item can make use of more space than 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.

Specified by:
expandingDirections in interface QLayoutItemInterface

geometry

public abstract QRect geometry()

Returns the rectangle covered by this layout item.

Specified by:
geometry in interface QLayoutItemInterface
See Also:
setGeometry

hasHeightForWidth

public boolean hasHeightForWidth()

Returns true if this layout's preferred height depends on its width; otherwise returns false. The default implementation returns false.

Reimplement this function in layout managers that support height for width.

Specified by:
hasHeightForWidth in interface QLayoutItemInterface
See Also:
heightForWidth, QWidget::heightForWidth

heightForWidth

public int heightForWidth(int arg__1)

Returns the preferred height for this layout item, given the width 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:

    int MyLayout::heightForWidth(int w) const
    {
        if (cache_dirty || cached_width != w) {
            // not all C++ compilers support "mutable"
            MyLayout *that = (MyLayout*)this;
            int h = calculateHeightForWidth(w);
            that->cached_hfw = h;
            return h;
        }
        return cached_hfw;
    }

Caching is strongly recommended; without it layout will take exponential time.

Specified by:
heightForWidth in interface QLayoutItemInterface
See Also:
hasHeightForWidth

invalidate

public void invalidate()

Invalidates any cached information in this layout item.

Specified by:
invalidate in interface QLayoutItemInterface

isEmpty

public abstract boolean isEmpty()

Implemented in subclasses to return whether this item is empty, i.e. whether it contains any widgets.

Specified by:
isEmpty in interface QLayoutItemInterface

layout

public QLayout layout()

If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned. This function provides type-safe casting.

Specified by:
layout in interface QLayoutItemInterface

maximumSize

public abstract QSize maximumSize()

Implemented in subclasses to return the maximum size of this item.

Specified by:
maximumSize in interface QLayoutItemInterface

minimumHeightForWidth

public int minimumHeightForWidth(int arg__1)

Returns the minimum height this widget needs for the given width, arg__1. The default implementation simply returns heightForWidth(arg__1).

Specified by:
minimumHeightForWidth in interface QLayoutItemInterface

minimumSize

public abstract QSize minimumSize()

Implemented in subclasses to return the minimum size of this item.

Specified by:
minimumSize in interface QLayoutItemInterface

setGeometry

public abstract void setGeometry(QRect arg__1)

Implemented in subclasses to set this item's geometry to arg__1.

Specified by:
setGeometry in interface QLayoutItemInterface
See Also:
geometry

sizeHint

public abstract QSize sizeHint()

Implemented in subclasses to return the preferred size of this item.

Specified by:
sizeHint in interface QLayoutItemInterface

spacerItem

public QSpacerItem spacerItem()

If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned. This function provides type-safe casting.

Specified by:
spacerItem in interface QLayoutItemInterface

widget

public QWidget widget()

If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned. This function provides type-safe casting.

Specified by:
widget in interface QLayoutItemInterface

setAlign

protected final void setAlign(Qt.AlignmentFlag... align)
Sets the alignment of this item to align.

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.


setAlign

protected final void setAlign(Qt.Alignment align)
Sets the alignment of this item to align.

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.


align

protected final Qt.Alignment align()
Returns the alignment of this QlayoutItem.


fromNativePointer

public static QLayoutItem fromNativePointer(QNativePointer nativePointer)
This function returns the QLayoutItem instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.