Q3WidgetStack Class

The Q3WidgetStack class provides a stack of widgets of which only the top widget is user-visible. 更多...

頭: #include <Q3WidgetStack>
繼承: Q3Frame

公共函數

Q3WidgetStack (QWidget * parent , const char * name = 0, Qt::WindowFlags f = 0)
~Q3WidgetStack ()
int addWidget (QWidget * w , int id = -1)
int id (QWidget * widget ) const
void removeWidget (QWidget * w )
QWidget * visibleWidget () const
QWidget * widget (int id ) const

重實現公共函數

virtual QSize minimumSizeHint () const
virtual void setVisible (bool visible )
virtual QSize sizeHint () const

公共槽

void raiseWidget (int id )
void raiseWidget (QWidget * w )

信號

void aboutToShow (int id )
void aboutToShow (QWidget * widget )

保護函數

virtual void setChildGeometries ()

重實現保護函數

virtual void childEvent (QChildEvent * e )
virtual bool event (QEvent * e )
virtual void frameChanged ()
virtual void resizeEvent (QResizeEvent * e )

額外繼承成員

詳細描述

The Q3WidgetStack class provides a stack of widgets of which only the top widget is user-visible.

The application programmer can move any widget to the top of the stack at any time using raiseWidget (), and add or remove widgets using addWidget () 和 removeWidget (). It is not sufficient to pass the widget stack as parent to a widget which should be inserted into the widgetstack.

visibleWidget () is the get 相當於 raiseWidget (); it returns a pointer to the widget that is currently at the top of the stack.

Q3WidgetStack also provides the ability to manipulate widgets through application-specified integer IDs. You can also translate from widget pointers to IDs using id () and from IDs to widget pointers using widget (). These numeric IDs are unique (per Q3WidgetStack , not globally), but Q3WidgetStack does not attach any additional meaning to them.

The default widget stack is frameless, but you can use the usual Q3Frame functions (such as setFrameStyle ()) to add a frame.

Q3WidgetStack provides a signal, aboutToShow (), which is emitted just before a managed widget is shown.

另請參閱 Q3TabDialog , QTabWidget , QTabBar ,和 Q3Frame .

成員函數文檔編製

Q3WidgetStack:: Q3WidgetStack ( QWidget * parent , const char * name = 0, Qt::WindowFlags f = 0)

Constructs an empty widget stack.

The parent , name and f 自變量被傳遞給 Q3Frame 構造函數。

Q3WidgetStack:: ~Q3WidgetStack ()

銷毀對象並釋放任何分配資源。

[signal] void Q3WidgetStack:: aboutToShow ( int id )

This signal is emitted just before a managed widget is shown if that managed widget has an ID != -1. The id parameter is the numeric ID of the widget.

若調用 visibleWidget () in a slot connected to aboutToShow(), the widget it returns is the one that is currently visible, not the one that is about to be shown.

注意: 信號 aboutToShow 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:

connect(3WidgetStack, static_cast<void(Q3WidgetStack::*)(int)>(&Q3WidgetStack::aboutToShow),
    [=](int id){ /* ... */ });
					

[signal] void Q3WidgetStack:: aboutToShow ( QWidget * widget )

這是重載函數。

This signal is emitted just before a managed widget is shown. The argument is a pointer to the widget .

若調用 visibleWidget () in a slot connected to aboutToShow (), the widget returned is the one that is currently visible, not the one that is about to be shown.

注意: 信號 aboutToShow 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:

connect(3WidgetStack, static_cast<void(Q3WidgetStack::*)(QWidget *)>(&Q3WidgetStack::aboutToShow),
    [=](QWidget *widget){ /* ... */ });
					

int Q3WidgetStack:: addWidget ( QWidget * w , int id = -1)

添加 Widget w to this stack of widgets, with ID id .

If you pass an id >= 0 this ID is used. If you pass an id of -1 (the default), the widgets will be numbered automatically. If you pass -2 a unique negative integer will be generated. No widget has an ID of -1. Returns the ID or -1 on failure (e.g. w is 0).

If you pass an id that is already used, then a unique negative integer will be generated to prevent two widgets having the same id.

w already exists in the stack the widget will be removed first.

w is not a child of this Q3WidgetStack moves it using reparent ().

[virtual protected] void Q3WidgetStack:: childEvent ( QChildEvent * e )

重實現自 QObject::childEvent ().

[virtual protected] bool Q3WidgetStack:: event ( QEvent * e )

重實現自 QObject::event ().

[virtual protected] void Q3WidgetStack:: frameChanged ()

重實現自 Q3Frame::frameChanged ().

int Q3WidgetStack:: id ( QWidget * widget ) const

Returns the ID of the widget . Returns -1 if widget is 0 or is not being managed by this widget stack.

另請參閱 widget () 和 addWidget ().

[虛擬] QSize Q3WidgetStack:: minimumSizeHint () const

重實現自 QWidget::minimumSizeHint ().

[slot] void Q3WidgetStack:: raiseWidget ( int id )

Raises the widget with ID id to the top of the widget stack.

另請參閱 visibleWidget ().

[slot] void Q3WidgetStack:: raiseWidget ( QWidget * w )

這是重載函數。

Raises widget w to the top of the widget stack.

void Q3WidgetStack:: removeWidget ( QWidget * w )

Removes widget w from this stack of widgets. Does not delete w 。若 w is the currently visible widget, no other widget is substituted.

另請參閱 visibleWidget () 和 raiseWidget ().

[virtual protected] void Q3WidgetStack:: resizeEvent ( QResizeEvent * e )

重實現自 QWidget::resizeEvent ().

[virtual protected] void Q3WidgetStack:: setChildGeometries ()

Fixes up the children's geometries.

[虛擬] void Q3WidgetStack:: setVisible ( bool visible )

重實現自 QWidget::setVisible ().

[虛擬] QSize Q3WidgetStack:: sizeHint () const

重實現自 QWidget::sizeHint ().

QWidget * Q3WidgetStack:: visibleWidget () const

Returns the currently visible widget (the one at the top of the stack), or 0 if nothing is currently being shown.

另請參閱 aboutToShow (), id (),和 raiseWidget ().

QWidget * Q3WidgetStack:: widget ( int id ) const

Returns the widget with ID id . Returns 0 if this widget stack does not manage a widget with ID id .

另請參閱 id () 和 addWidget ().