Q3TabDialog Class

The Q3TabDialog 类提供选项卡式 Widget 堆栈。 更多...

头: #include <Q3TabDialog>
继承: QDialog

公共函数

Q3TabDialog (QWidget * parent = 0, const char * name = 0, bool modal = false, Qt::WindowFlags f = 0)
~Q3TabDialog ()
void addTab (QWidget * child , const QString & label )
void addTab (QWidget * child , const QIcon & iconset , const QString & label )
void changeTab (QWidget * w , const QIcon & iconset , const QString & label )
void changeTab (QWidget * w , const QString & label )
QWidget * currentPage () const
bool hasApplyButton () const
bool hasCancelButton () const
bool hasDefaultButton () const
bool hasHelpButton () const
bool hasOkButton () const
void insertTab (QWidget * child , const QString & label , int index = -1)
void insertTab (QWidget * child , const QIcon & iconset , const QString & label , int index = -1)
bool isTabEnabled (QWidget * w ) const
void removePage (QWidget * w )
void setApplyButton (const QString & text )
void setApplyButton ()
void setCancelButton (const QString & text )
void setCancelButton ()
void setDefaultButton (const QString & text )
void setDefaultButton ()
void setFont (const QFont & font )
void setHelpButton (const QString & text )
void setHelpButton ()
void setOkButton (const QString & text )
void setOkButton ()
void setTabEnabled (QWidget * w , bool enable )
void showPage (QWidget * w )
QString tabLabel (QWidget * w )

信号

void aboutToShow ()
void applyButtonPressed ()
void cancelButtonPressed ()
void currentChanged (QWidget * widget )
void defaultButtonPressed ()
void helpButtonPressed ()
void selected (const QString & name )

保护函数

void setTabBar (QTabBar * tb )
QTabBar * tabBar () const

重实现保护函数

virtual void paintEvent (QPaintEvent *)
virtual void resizeEvent (QResizeEvent * e )
virtual void showEvent (QShowEvent * e )

额外继承成员

详细描述

The Q3TabDialog 类提供选项卡式 Widget 堆栈。

A tabbed dialog is one in which several "tab pages" are available. By clicking on a tab page's tab or by pressing the indicated Alt+ letter key combination, the user can select which tab page they want to use.

Q3TabDialog provides a tab bar consisting of single row of tabs at the top; each tab has an associated widget which is that tab's tab page. In addition, Q3TabDialog provides an OK button and the following optional buttons: Apply, Cancel, Defaults and Help.

平常方式是使用 Q3TabDialog is to do the following in the constructor:

  1. 创建 Q3TabDialog .
  2. 创建 QWidget for each of the pages in the tab dialog, insert children into it, set up geometry management for it, and use addTab () (or insertTab ()) to set up a tab and keyboard accelerator for it.
  3. Set up the buttons for the tab dialog using setOkButton (), setApplyButton (), setDefaultsButton(), setCancelButton () 和 setHelpButton ().
  4. Connect to the signals and slots.

If you don't call addTab () the page you have created will not be visible. Don't confuse the object name you supply to the QWidget constructor and the tab label you supply to addTab (); addTab () takes user-visible name that appears on the widget's tab and may identify an accelerator, whereas the widget name is used primarily for debugging.

Almost all applications have to connect the applyButtonPressed () signal to something. applyButtonPressed () is emitted when either OK or Apply is clicked, and your slot must copy the dialog's state into the application.

There are also several other signals which may be useful:

  • cancelButtonPressed () is emitted when the user clicks Cancel.
  • defaultButtonPressed () is emitted when the user clicks Defaults; the slot it is connected to should reset the state of the dialog to the application defaults.
  • helpButtonPressed () is emitted when the user clicks Help.
  • aboutToShow () is emitted at the start of show(); if there is any chance that the state of the application may change between the creation of the tab dialog and the time show() is called, you must connect this signal to a slot that resets the state of the dialog.
  • currentChanged () 被发射当用户选择页面时。

可以随时启用或禁用每选项卡 (见 setTabEnabled ()). If a tab is enabled the tab text is drawn in black and the user can select that tab. If it is disabled the tab is drawn in a different way and the user cannot select that tab. Note that even if a tab is disabled, the page can still be visible; for example, if all of the tabs happen to be disabled.

You can change a tab's label and iconset using changeTab (). A tab page can be removed with removePage () and shown with showPage (). The current page is given by currentPage ().

Q3TabDialog does not support tabs on the sides or bottom, nor can you set or retrieve the visible page. If you need more functionality than Q3TabDialog provides, consider creating a QDialog and using a QTabBar with QTabWidgets.

大多数功能在 Q3TabDialog 的提供是通过 QTabWidget .

成员函数文档编制

Q3TabDialog:: Q3TabDialog ( QWidget * parent = 0, const char * name = 0, bool modal = false, Qt::WindowFlags f = 0)

构造 Q3TabDialog with only an OK button. The parent , name , modal 和 Widget 标志 f , arguments are passed on to the QDialog 构造函数。

Q3TabDialog:: ~Q3TabDialog ()

Destroys the tab dialog.

[signal] void Q3TabDialog:: aboutToShow ()

This signal is emitted by show() when it is time to set the state of the dialog's contents. The dialog should reflect the current state of the application when it appears; if there is any possibility that the state of the application may change between the time you call Q3TabDialog () and show(), you should set the dialog's state in a slot and connect this signal to it.

This applies mainly to Q3TabDialog objects that are kept around hidden, rather than being created, shown, and deleted afterwards.

另请参阅 applyButtonPressed (), QWidget::show (),和 cancelButtonPressed ().

void Q3TabDialog:: addTab ( QWidget * child , const QString & label )

Adds another tab and page to the tab view.

The new page is child ; the tab's label is label . Note the difference between the widget name (which you supply to widget constructors and to setTabEnabled (), for example) and the tab label. The name is internal to the program and invariant, whereas the label is shown on-screen and may vary according to language and other factors.

若选项卡的 label contains an ampersand, the letter following the ampersand is used as an accelerator for the tab, e.g. if the label is "Bro&wse" then Alt+W becomes an accelerator which will move the focus to this tab.

If you call addTab() after show() the screen will flicker and the user may be confused.

另请参阅 insertTab ().

void Q3TabDialog:: addTab ( QWidget * child , const QIcon & iconset , const QString & label )

这是重载函数。

This version of the function shows the iconset as well as the label on the tab of child .

[signal] void Q3TabDialog:: applyButtonPressed ()

This signal is emitted when either the Apply or OK button is clicked.

It should be connected to a slot (or several slots) that change the application's state according to the state of the dialog.

另请参阅 cancelButtonPressed (), defaultButtonPressed (),和 setApplyButton ().

[signal] void Q3TabDialog:: cancelButtonPressed ()

This signal is emitted when the Cancel button is clicked. It is automatically connected to QDialog::reject (), which will hide the dialog.

The Cancel button should not change the application's state at all, so you should generally not need to connect it to any slot.

另请参阅 applyButtonPressed (), defaultButtonPressed (),和 setCancelButton ().

void Q3TabDialog:: changeTab ( QWidget * w , const QIcon & iconset , const QString & label )

Changes tab page w 's iconset to iconset and label to label .

void Q3TabDialog:: changeTab ( QWidget * w , const QString & label )

这是重载函数。

定义新的 label for the tab of page w

[signal] void Q3TabDialog:: currentChanged ( QWidget * widget )

This signal is emitted whenever the current page changes. widget is the new current page.

另请参阅 currentPage (), showPage (),和 tabLabel ().

QWidget * Q3TabDialog:: currentPage () const

返回由选项卡对话框所显示的目前页面指针。选项卡对话框会尽力确保此值从不为 0 (但若足够努力,可以)。

[signal] void Q3TabDialog:: defaultButtonPressed ()

This signal is emitted when the Defaults button is pressed. It should reset the dialog (but not the application) to the "factory defaults".

The application's state should not be changed until the user clicks Apply or OK.

另请参阅 applyButtonPressed (), cancelButtonPressed (),和 setDefaultButton ().

bool Q3TabDialog:: hasApplyButton () const

Returns true if the tab dialog has an Apply button; otherwise returns false.

hasDefaultButton ()

另请参阅 setApplyButton (), applyButtonPressed (),和 hasCancelButton ().

bool Q3TabDialog:: hasCancelButton () const

Returns true if the tab dialog has a Cancel button; otherwise returns false.

hasDefaultButton ()

另请参阅 setCancelButton (), cancelButtonPressed (),和 hasApplyButton ().

bool Q3TabDialog:: hasDefaultButton () const

Returns true if the tab dialog has a Defaults button; otherwise returns false.

hasCancelButton ()

另请参阅 setDefaultButton (), defaultButtonPressed (),和 hasApplyButton ().

bool Q3TabDialog:: hasHelpButton () const

Returns true if the tab dialog has a Help button; otherwise returns false.

hasCancelButton ()

另请参阅 setHelpButton (), helpButtonPressed (),和 hasApplyButton ().

bool Q3TabDialog:: hasOkButton () const

Returns true if the tab dialog has an OK button; otherwise returns false.

hasDefaultButton ()

另请参阅 setOkButton (), hasApplyButton (),和 hasCancelButton ().

[signal] void Q3TabDialog:: helpButtonPressed ()

This signal is emitted when the Help button is pressed. It could be used to present information about how to use the dialog.

另请参阅 applyButtonPressed (), cancelButtonPressed (),和 setHelpButton ().

void Q3TabDialog:: insertTab ( QWidget * child , const QString & label , int index = -1)

Inserts another tab and page to the tab view.

The new page is child ; the tab's label is label . Note the difference between the widget name (which you supply to widget constructors and to setTabEnabled (), for example) and the tab label. The name is internal to the program and invariant, whereas the label is shown on-screen and may vary according to language and other factors.

若选项卡的 label contains an ampersand, the letter following the ampersand is used as an accelerator for the tab, e.g. if the label is "Bro&wse" then Alt+W becomes an accelerator which will move the focus to this tab.

index is not specified, the tab is simply added. Otherwise it is inserted at the specified position.

If you call insertTab() after show(), the screen will flicker and the user may be confused.

另请参阅 addTab ().

void Q3TabDialog:: insertTab ( QWidget * child , const QIcon & iconset , const QString & label , int index = -1)

这是重载函数。

This version of the function shows the iconset as well as the label on the tab of child .

bool Q3TabDialog:: isTabEnabled ( QWidget * w ) const

Returns true if the page w is enabled; otherwise returns false.

另请参阅 setTabEnabled () 和 QWidget::isEnabled ().

[virtual protected] void Q3TabDialog:: paintEvent ( QPaintEvent *)

重实现自 QWidget::paintEvent ().

void Q3TabDialog:: removePage ( QWidget * w )

Removes page w from this stack of widgets. Does not delete w .

另请参阅 showPage () 和 QTabWidget::removePage ().

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

重实现自 QWidget::resizeEvent ().

[signal] void Q3TabDialog:: selected (const QString & name )

This signal is emitted whenever a tab is selected (raised), including during the first show(). name is the name of the selected tab.

另请参阅 raise ().

void Q3TabDialog:: setApplyButton (const QString & text )

Adds an Apply button to the dialog. The button's text is set to text .

The Apply button should apply the current settings in the dialog box to the application while keeping the dialog visible.

When Apply is clicked, the applyButtonPressed () 信号发射。

text is an empty string, no button is shown.

另请参阅 hasApplyButton (), setCancelButton (), setDefaultButton (),和 applyButtonPressed ().

void Q3TabDialog:: setApplyButton ()

这是重载函数。

Adds an Apply button to the dialog. The button's text is set to a localizable "Apply".

void Q3TabDialog:: setCancelButton (const QString & text )

Adds a Cancel button to the dialog. The button's text is set to text .

The cancel button should always return the application to the state it was in before the tab view popped up, or if the user has clicked Apply, back to the state immediately after the last Apply.

When Cancel is clicked, the cancelButtonPressed () signal is emitted. The dialog is closed at the same time.

text is an empty string, no button is shown.

另请参阅 hasCancelButton (), setApplyButton (), setDefaultButton (),和 cancelButtonPressed ().

void Q3TabDialog:: setCancelButton ()

这是重载函数。

Adds a Cancel button to the dialog. The button's text is set to a localizable "Cancel".

void Q3TabDialog:: setDefaultButton (const QString & text )

Adds a Defaults button to the dialog. The button's text is set to text .

The Defaults button should set the dialog (but not the application) back to the application defaults.

When Defaults is clicked, the defaultButtonPressed () 信号发射。

text is an empty string, no button is shown.

另请参阅 hasDefaultButton (), setApplyButton (), setCancelButton (),和 defaultButtonPressed ().

void Q3TabDialog:: setDefaultButton ()

这是重载函数。

Adds a Defaults button to the dialog. The button's text is set to a localizable "Defaults".

void Q3TabDialog:: setFont (const QFont & font )

Sets the font for the tabs to font .

If the widget is visible, the display is updated with the new font immediately. There may be some geometry changes, depending on the size of the old and new fonts.

void Q3TabDialog:: setHelpButton (const QString & text )

Adds a Help button to the dialog. The button's text is set to text .

When Help is clicked, the helpButtonPressed () 信号发射。

text is an empty string, no button is shown.

另请参阅 hasHelpButton (), setApplyButton (), setCancelButton (),和 helpButtonPressed ().

void Q3TabDialog:: setHelpButton ()

这是重载函数。

Adds a Help button to the dialog. The button's text is set to a localizable "Help".

void Q3TabDialog:: setOkButton (const QString & text )

Adds an OK button to the dialog and sets the button's text to text .

When the OK button is clicked, the applyButtonPressed () signal is emitted, and the current settings in the dialog box should be applied to the application. The dialog then closes.

text is an empty string, no button is shown.

另请参阅 hasOkButton (), setCancelButton (), setDefaultButton (),和 applyButtonPressed ().

void Q3TabDialog:: setOkButton ()

这是重载函数。

Adds an OK button to the dialog. The button's text is set to a localizable "OK".

[protected] void Q3TabDialog:: setTabBar ( QTabBar * tb )

Replaces the QTabBar heading the dialog by the given tab bar, tb 。注意,这必须被调用 before 任何选项卡被添加,或行为不确定。

另请参阅 tabBar ().

void Q3TabDialog:: setTabEnabled ( QWidget * w , bool enable )

enable is true the page w is enabled; otherwise w 被禁用。页面选项卡被适当重新绘制。

QTabWidget 使用 QWidget::setEnabled () 在内部,而不是保持单独标志。

Note that even a disabled tab and tab page may be visible. If the page is already visible QTabWidget will not hide it; if all the pages are disabled QTabWidget 将展示它们之一。

另请参阅 isTabEnabled () 和 QWidget::setEnabled ().

[virtual protected] void Q3TabDialog:: showEvent ( QShowEvent * e )

重实现自 QWidget::showEvent ().

void Q3TabDialog:: showPage ( QWidget * w )

Ensures that widget w is shown. This is mainly useful for accelerators.

警告: If used carelessly, this function can easily surprise or confuse the user.

另请参阅 QTabBar::setCurrentTab ().

[protected] QTabBar * Q3TabDialog:: tabBar () const

Returns the currently set QTabBar .

另请参阅 setTabBar ().

QString Q3TabDialog:: tabLabel ( QWidget * w )

Returns the text in the tab for page w .