|
|
||||||||||
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.core.QObject
com.trolltech.qt.gui.QLayout
com.trolltech.qt.gui.QStackedLayout
public class QStackedLayout
The QStackedLayout class provides a stack of widgets where only one widget is visible at a time.
QStackedLayout can be used to create a user interface similar to the one provided by QTabWidget. There is also a convenience QStackedWidget class built on top of QStackedLayout.
A QStackedLayout can be populated with a number of child widgets ("pages"). For example:
QWidget *firstPageWidget = new QWidget; QWidget *secondPageWidget = new QWidget; QWidget *thirdPageWidget = new QWidget; QStackedLayout *stackedLayout = new QStackedLayout; stackedLayout->addWidget(firstPageWidget); stackedLayout->addWidget(secondPageWidget); stackedLayout->addWidget(thirdPageWidget); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(stackedLayout); setLayout(mainLayout);
QStackedLayout provides no intrinsic means for the user to switch page. This is typically done through a QComboBox or a QListWidget that stores the titles of the QStackedLayout's pages. For example:
QComboBox *pageComboBox = new QComboBox; pageComboBox->addItem(tr("Page 1")); pageComboBox->addItem(tr("Page 2")); pageComboBox->addItem(tr("Page 3")); connect(pageComboBox, SIGNAL(activated(int)), stackedLayout, SLOT(setCurrentIndex(int)));
When populating a layout, the widgets are added to an internal list. The indexOf function returns the index of a widget in that list. The widgets can either be added to the end of the list using the addWidget function, or inserted at a given index using the insertWidget function. The removeWidget function removes the widget at the given index from the layout. The number of widgets contained in the layout, can be obtained using the count function.
The widget function returns the widget at a given index position. The index of the widget that is shown on screen is given by currentIndex and can be changed using setCurrentIndex. In a similar manner, the currently shown widget can be retrieved using the currentWidget function, and altered using the setCurrentWidget function.
Whenever the current widget in the layout changes or a widget is removed from the layout, the currentChanged and widgetRemoved signals are emitted respectively.
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<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> |
Field Summary | |
---|---|
QSignalEmitter.Signal1<java.lang.Integer> |
currentChanged
This signal is emitted whenever the current widget in the layout changes. |
QSignalEmitter.Signal1<java.lang.Integer> |
widgetRemoved
This signal is emitted whenever a widget is removed from the layout. |
Constructor Summary | |
---|---|
QStackedLayout()
Constructs a QStackedLayout with no parent. |
|
QStackedLayout(QLayout parentLayout)
Constructs a new QStackedLayout and inserts it into the given parentLayout. |
|
QStackedLayout(QWidget parent)
Constructs a new QStackedLayout with the given parent. |
Method Summary | |
---|---|
void |
addItem(QLayoutItemInterface item)
This function is reimplemented for internal reasons. |
int |
addStackedWidget(QWidget w)
Adds the given w to the end of this layout and returns the index position of the w. |
int |
count()
Returns the number of widgets contained in the layout. |
int |
currentIndex()
Returns the index position of the widget that is visible. |
QWidget |
currentWidget()
Returns the current widget, or 0 if there are no widgets in this layout. |
static QStackedLayout |
fromNativePointer(QNativePointer nativePointer)
This function returns the QStackedLayout instance pointed to by nativePointer |
int |
insertWidget(int index,
QWidget w)
Inserts the given w at the given index in this QStackedLayout. |
QLayoutItemInterface |
itemAt(int arg__1)
This function is reimplemented for internal reasons. |
QSize |
minimumSize()
This function is reimplemented for internal reasons. |
void |
setCurrentIndex(int index)
Sets the index position of the widget that is visible to index. |
void |
setCurrentWidget(QWidget w)
Sets the current widget to be the specified w. |
void |
setGeometry(QRect rect)
This function is reimplemented for internal reasons. |
QSize |
sizeHint()
This function is reimplemented for internal reasons. |
QLayoutItemInterface |
takeAt(int arg__1)
This function is reimplemented for internal reasons. |
QWidget |
widget()
This function is reimplemented for internal reasons. |
QWidget |
widget(int arg__1)
Returns the widget at the given arg__1, or 0 if there is no widget at the given position. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
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 |
Field Detail |
---|
public final QSignalEmitter.Signal1<java.lang.Integer> currentChanged
This signal is emitted whenever the current widget in the layout changes. The index specifies the index of the new current widget.
public final QSignalEmitter.Signal1<java.lang.Integer> widgetRemoved
This signal is emitted whenever a widget is removed from the layout. The widget's index is passed as parameter.
Constructor Detail |
---|
public QStackedLayout()
Constructs a QStackedLayout with no parent.
This QStackedLayout must be installed on a widget later on to become effective.
public QStackedLayout(QWidget parent)
Constructs a new QStackedLayout with the given parent.
This layout will install itself on the parent widget and manage the geometry of its children.
public QStackedLayout(QLayout parentLayout)
Constructs a new QStackedLayout and inserts it into the given parentLayout.
Method Detail |
---|
public final int addStackedWidget(QWidget w)
Adds the given w to the end of this layout and returns the index position of the w.
If the QStackedLayout is empty before this function is called, the given w becomes the current widget.
public final int currentIndex()
Returns the index position of the widget that is visible.
The current index is -1 if there is no current widget.
public final QWidget currentWidget()
Returns the current widget, or 0 if there are no widgets in this layout.
public final int insertWidget(int index, QWidget w)
Inserts the given w at the given index in this QStackedLayout. If index is out of range, the widget is appended (in which case it is the actual index of the w that is returned).
If the QStackedLayout is empty before this function is called, the given w becomes the current widget.
Inserting a new widget at an index less than or equal to the current index will increment the current index, but keep the current widget.
public final void setCurrentIndex(int index)
Sets the index position of the widget that is visible to index.
The current index is -1 if there is no current widget.
public final void setCurrentWidget(QWidget w)
Sets the current widget to be the specified w. The new current widget must already be contained in this stacked layout.
public final QWidget widget(int arg__1)
Returns the widget at the given arg__1, or 0 if there is no widget at the given position.
public void addItem(QLayoutItemInterface item)
This function is reimplemented for internal reasons.
addItem
in class QLayout
public int count()
Returns the number of widgets contained in the layout.
count
in class QLayout
public QLayoutItemInterface itemAt(int arg__1)
This function is reimplemented for internal reasons.
itemAt
in class QLayout
public QSize minimumSize()
This function is reimplemented for internal reasons.
minimumSize
in interface QLayoutItemInterface
minimumSize
in class QLayout
public void setGeometry(QRect rect)
This function is reimplemented for internal reasons.
setGeometry
in interface QLayoutItemInterface
setGeometry
in class QLayout
public QSize sizeHint()
This function is reimplemented for internal reasons.
sizeHint
in interface QLayoutItemInterface
sizeHint
in class QLayout
public QLayoutItemInterface takeAt(int arg__1)
This function is reimplemented for internal reasons.
takeAt
in class QLayout
public QWidget widget()
This function is reimplemented for internal reasons.
widget
in interface QLayoutItemInterface
widget
in class QLayout
public static QStackedLayout fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |