Q3ToolBar Class

The Q3ToolBar class provides a movable panel containing widgets such as tool buttons. 更多...

頭: #include <Q3ToolBar>
繼承: Q3DockWindow

特性

公共函數

Q3ToolBar (const QString & label , Q3MainWindow * parent , Qt::ToolBarDock dock = Qt::DockTop, bool newLine = false, const char * name = 0)
Q3ToolBar (const QString & label , Q3MainWindow * mainWindow , QWidget * parent , bool newLine = false, const char * name = 0, Qt::WindowFlags f = 0)
Q3ToolBar (Q3MainWindow * parent = 0, const char * name = 0)
~Q3ToolBar ()
void addSeparator ()
virtual void clear ()
QString label () const
Q3MainWindow * mainWindow () const
virtual void setLabel (const QString &)
virtual void setStretchableWidget (QWidget * w )

重實現公共函數

virtual bool event (QEvent * e )
virtual QSize minimumSizeHint () const
virtual void setOrientation (Qt::Orientation o )
virtual void setVisible (bool visible )

重實現保護函數

virtual void resizeEvent (QResizeEvent * e )

額外繼承成員

詳細描述

The Q3ToolBar class provides a movable panel containing widgets such as tool buttons.

A toolbar is a panel that contains a set of controls, usually represented by small icons. It's purpose is to provide quick access to frequently used commands or options. Within a Q3MainWindow the user can drag toolbars within and between the dock areas . Toolbars can also be dragged out of any dock area to float freely as top-level windows.

Q3ToolBar is a specialization of QDockWindow , and so provides all the functionality of a QDockWindow .

要使用 Q3ToolBar you simply create a Q3ToolBar as a child of a Q3MainWindow , create a number of QToolButton widgets (or other widgets) in left to right (or top to bottom) order and call addSeparator () when you want a separator. When a toolbar is floated the caption used is the label given in the constructor call. This can be changed with setLabel ().

You may use most widgets within a toolbar, with QToolButton and QComboBox being the most common. But note that the toolbar's actions must be Q3Action

If you create a new widget on an already visible Q3ToolBar , this widget will automatically become visible without needing a show () call. (This differs from every other Qt widget container. We recommend calling show () anyway since we hope to fix this anomaly in a future release.)

Q3ToolBars, like QDockWindows, are located in Q3DockArea s or float as top-level windows. Q3MainWindow provides four Q3DockAreas (top, left, right and bottom). When you create a new toolbar (as in the example above) as a child of a Q3MainWindow the toolbar will be added to the top dock area. You can move it to another dock area (or float it) by calling Q3MainWindow::moveDockWindow (). Dock areas lay out their windows in lines.

If the main window is resized so that the area occupied by the toolbar is too small to show all its widgets a little arrow button (which looks like a right-pointing chevron, '»') will appear at the right or bottom of the toolbar depending on its orientation. Clicking this button pops up a menu that shows the 'overflowing' items. QToolButtons are represented in the menu using their textLabel property, other QAbstractButton subclasses are represented using their text property, and QComboBoxes are represented as submenus, with the caption text being used in the submenu item.

Usually a toolbar will get precisely the space it needs. However, with setHorizontalStretchable (), setVerticalStretchable () 或 setStretchableWidget () you can tell the main window to expand the toolbar to fill all available space in the specified orientation.

The toolbar arranges its buttons either horizontally or vertically (see orientation () for details). Generally, Q3DockArea will set the orientation correctly for you, but you can set it yourself with setOrientation () and track any changes by connecting to the orientationChanged () 信號。

可以使用 clear () method to remove all items from a toolbar.

Toolbar (dock window)

A floating QToolbar (dock window)

另請參閱 QToolButton and Q3MainWindow .

特性文檔編製

label : QString

This property holds the toolbar's label.

If the toolbar is floated the label becomes the toolbar window's caption. There is no default label text.

訪問函數:

QString label () const
virtual void setLabel (const QString &)

成員函數文檔編製

Q3ToolBar:: Q3ToolBar (const QString & label , Q3MainWindow * parent , Qt::ToolBarDock dock = Qt::DockTop, bool newLine = false, const char * name = 0)

Constructs an empty toolbar.

The toolbar is called name and is a child of parent and is managed by parent . It is initially located in dock area dock and is labeled label 。若 newLine is true the toolbar will be placed on a new line in the dock area.

Q3ToolBar:: Q3ToolBar (const QString & label , Q3MainWindow * mainWindow , QWidget * parent , bool newLine = false, const char * name = 0, Qt::WindowFlags f = 0)

Constructs an empty horizontal toolbar.

The toolbar is called name and is a child of parent and is managed by mainWindow label and newLine parameters are passed straight to Q3MainWindow::addDockWindow (). name and the widget flags f 被傳遞給 Q3DockWindow 構造函數。

Use this constructor if you want to create torn-off (undocked, floating) toolbars or toolbars in the 狀態欄 .

Q3ToolBar:: Q3ToolBar ( Q3MainWindow * parent = 0, const char * name = 0)

這是重載函數。

Constructs an empty toolbar called name ,采用父級 parent , in its parent 's top dock area, without any label and without requiring a newline.

Q3ToolBar:: ~Q3ToolBar ()

析構函數。

void Q3ToolBar:: addSeparator ()

Adds a separator to the right/bottom of the toolbar.

[虛擬] void Q3ToolBar:: clear ()

Deletes all the toolbar's child widgets.

[虛擬] bool Q3ToolBar:: event ( QEvent * e )

重實現自 QObject::event ().

Q3MainWindow * Q3ToolBar:: mainWindow () const

返迴指針指嚮 Q3MainWindow which manages this toolbar.

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

重實現自 QWidget::minimumSizeHint ().

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

重實現自 QWidget::resizeEvent ().

[虛擬] void Q3ToolBar:: setOrientation ( Qt::Orientation o )

重實現自 Q3DockWindow::setOrientation ().

[虛擬] void Q3ToolBar:: setStretchableWidget ( QWidget * w )

Sets the widget w to be expanded if this toolbar is requested to stretch.

The request to stretch might occur because Q3MainWindow right-justifies the dock area the toolbar is in, or because this toolbar's isVerticalStretchable () 或 isHorizontalStretchable () is set to true.

If you call this function and the toolbar is not yet stretchable, setStretchable() is called.

另請參閱 Q3MainWindow::setRightJustification (), setVerticalStretchable (),和 setHorizontalStretchable ().

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

重實現自 QWidget::setVisible ().