QToolBar Class Reference

[QtGui module]

该QToolBar类提供了一个可移动的面板,它包含了一组控件。More…

继承QWidget

Methods

  • __init__ (self, QString title, QWidget parent = None)
  • __init__ (self, QWidget parent = None)
  • QAction actionAt (self, QPoint p)
  • QAction actionAt (self, int ax, int ay)
  • actionEvent (self, QActionEvent event)
  • QRect actionGeometry (self, QAction action)
  • addAction (self, QAction action)
  • QAction addAction (self, QString text)
  • QAction addAction (self, QIcon icon, QString text)
  • QAction addAction (self, QString text, QObject receiver, SLOT()SLOT() member)
  • QAction addAction (self, QString text, callable receiver)
  • QAction addAction (self, QIcon icon, QString text, QObject receiver, SLOT()SLOT() member)
  • QAction addAction (self, QIcon icon, QString text, callable receiver)
  • QAction addSeparator (self)
  • QAction addWidget (self, QWidget widget)
  • Qt.ToolBarAreas allowedAreas (self)
  • changeEvent (self, QEvent event)
  • childEvent (self, QChildEvent event)
  • clear (self)
  • bool event (self, QEvent event)
  • QSize iconSize (self)
  • initStyleOption (self, QStyleOptionToolBar option)
  • QAction insertSeparator (self, QAction before)
  • QAction insertWidget (self, QAction before, QWidget widget)
  • bool isAreaAllowed (self, Qt.ToolBarArea area)
  • bool isFloatable (self)
  • bool isFloating (self)
  • bool isMovable (self)
  • Qt.Orientation orientation (self)
  • paintEvent (self, QPaintEvent event)
  • resizeEvent (self, QResizeEvent event)
  • setAllowedAreas (self, Qt.ToolBarAreas areas)
  • setFloatable (self, bool floatable)
  • setIconSize (self, QSize iconSize)
  • setMovable (self, bool movable)
  • setOrientation (self, Qt.Orientation orientation)
  • setToolButtonStyle (self, Qt.ToolButtonStyle toolButtonStyle)
  • QAction toggleViewAction (self)
  • Qt.ToolButtonStyle toolButtonStyle (self)
  • QWidget widgetForAction (self, QAction action)

Qt Signals

  • void actionTriggered (QAction *)
  • void allowedAreasChanged (Qt::ToolBarAreas)
  • void iconSizeChanged (const QSize&)
  • void movableChanged (bool)
  • void orientationChanged (Qt::Orientation)
  • void toolButtonStyleChanged (Qt::ToolButtonStyle)
  • void topLevelChanged (bool)
  • void visibilityChanged (bool)

Detailed Description

该QToolBar类提供了一个可移动的面板,它包含了一组控件。

工具栏按钮加入添加actions,使用addAction()或insertAction( ) 。按钮组,可以使用分离addSeparator()或insertSeparator( ) 。如果工具栏按钮是不合适的,一个部件可以被插入,而不是使用addWidget()或insertWidget();合适的窗口小部件的实例是QSpinBoxQDoubleSpinBoxQComboBox。当按下工具栏按钮,它发出的actionTriggered()信号。

工具栏可以被固定在适当位置中的特定区域(例如,在窗口的顶部) ,或者它可以是可移动的(isMovable( ) )工具栏区域之间,见allowedAreas()和isAreaAllowed( ) 。

当一个工具栏调整大小以这样一种方式,它是太小,无法显示其包含的所有项目,分机键会出现在工具栏上的最后一个项目。按分机键会弹出包含目前不适合工具栏上的项目菜单。

当QToolBar不是一个孩子QMainWindow,它失去了使用带有添加到工具栏小工具来填充扩展弹出的能力addWidget( ) 。请使用通过继承创建控件的行为QWidgetAction和实施QWidgetAction.createWidget( )来代替。


Method Documentation

  1. QToolBar.__init__ (self, QString title, QWidget parent = None)

parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。

构造一个QToolBar用给定的parent

给定的窗口title标识的工具栏,并显示在所提供的上下文菜单QMainWindow

See also setWindowTitle( ) 。

  1. QToolBar.__init__ (self, QWidget parent = None)

parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。

构造一个QToolBar用给定的parent

  1. QAction QToolBar.actionAt (self, QPoint p)

[

返回点的动作p。该函数返回零,如果发现任何行动。

]($docs-qaction.html)

See also QWidget.childAt( ) 。

  1. QAction QToolBar.actionAt (self, int ax, int ay)

[

这是一个重载函数。

返回行动在点xy。该函数返回零,如果发现任何行动。

  1. QToolBar.actionEvent (self, QActionEvent event)

]($docs-qaction.html)

从重新实现QWidget.actionEvent( ) 。

  1. QRect QToolBar.actionGeometry (self, QAction action)

[

  1. QToolBar.addAction (self, QAction action)

这是一个重载函数。

追加行动action对行动的工具栏的列表。

]($docs-qrect.html)

See also QMenu.addAction()和QWidget.addAction( ) 。

  1. QAction QToolBar.addAction (self, QString text)

[

这是一个重载函数。

创建一个新的动作与给定text。这个动作被添加到工具栏的末尾。

]($docs-qaction.html)

  1. QAction QToolBar.addAction (self, QIcon icon, QString text)

[

这是一个重载函数。

创建一个新的动作与给定icontext。这个动作被添加到工具栏的末尾。

]($docs-qaction.html)

  1. QAction QToolBar.addAction (self, QString text, QObject receiver, SLOT()SLOT() member)

[

这是一个重载函数。

]($docs-qaction.html)

创建一个新的动作与给定text。这个动作被添加到工具栏的末尾。动作的triggered()信号被连接到memberreceiver

  1. QAction QToolBar.addAction (self, QString text, callable receiver)

[

这是一个重载函数。

]($docs-qaction.html)

创建带有图标的新动作icon和文本text。这个动作被添加到工具栏的末尾。动作的triggered()信号被连接到memberreceiver

  1. QAction QToolBar.addAction (self, QIcon icon, QString text, QObject receiver, SLOT()SLOT() member)

  1. QAction QToolBar.addAction (self, QIcon icon, QString text, callable receiver)

  1. QAction QToolBar.addSeparator (self)

[

添加分隔到工具栏的末尾。

]($docs-qaction.html)

See also insertSeparator( ) 。

  1. QAction QToolBar.addWidget (self, QWidget widget)

[

widget说法有它的所有权转移给Qt的。

将给定widget到工具栏与工具栏的最后一个项目。

该工具栏需要的所有权widget

]($docs-qaction.html)

如果添加QToolButton用这种方法,工具栏的Qt.ToolButtonStyle将不被尊重。

Note:您应该使用QAction.setVisible( )来改变控件的可见性。运用QWidget.setVisible( )QWidget.show()和QWidget.hide( )不起作用。

See also insertWidget( ) 。

  1. Qt.ToolBarAreas QToolBar.allowedAreas (self)

[

  1. QToolBar.changeEvent (self, QEvent event)

]($docs-index.htm)

从重新实现QWidget.changeEvent( ) 。

  1. QToolBar.childEvent (self, QChildEvent event)

从重新实现QObject.childEvent( ) 。

  1. QToolBar.clear (self)

移除工具栏上的所有操作。

See also removeAction( ) 。

  1. bool QToolBar.event (self, QEvent event)

从重新实现QObject.event( ) 。

  1. QSize QToolBar.iconSize (self)

[

  1. QToolBar.initStyleOption (self, QStyleOptionToolBar option)

](qsize.html)

  1. QAction QToolBar.insertSeparator (self, QAction before)

[

插入分隔到工具栏与相关的工具栏项前before行动。

]($docs-qaction.html)

See also addSeparator( ) 。

  1. QAction QToolBar.insertWidget (self, QAction before, QWidget widget)

[

widget说法有它的所有权转移给Qt的。

插入给定widget与相关的工具栏项前before行动。

]($docs-qaction.html)

注意:您应该使用QAction.setVisible( )来改变控件的可见性。运用QWidget.setVisible( )QWidget.show()和QWidget.hide( )不起作用。

See also addWidget( ) 。

  1. bool QToolBar.isAreaAllowed (self, Qt.ToolBarArea area)

返回True如果这个工具栏可停靠在给定的area否则返回False 。

  1. bool QToolBar.isFloatable (self)
  1. bool QToolBar.isFloating (self)
  1. bool QToolBar.isMovable (self)
  1. Qt.Orientation QToolBar.orientation (self)

[

  1. QToolBar.paintEvent (self, QPaintEvent event)

]($docs-qt.html#Orientation-enum)

从重新实现QWidget.paintEvent( ) 。

  1. QToolBar.resizeEvent (self, QResizeEvent event)

从重新实现QWidget.resizeEvent( ) 。

  1. QToolBar.setAllowedAreas (self, Qt.ToolBarAreas areas)
  1. QToolBar.setFloatable (self, bool floatable)
  1. QToolBar.setIconSize (self, QSize iconSize)

这种方法也是一个Qt槽与C + +的签名void setIconSize(const QSize&)

  1. QToolBar.setMovable (self, bool movable)
  1. QToolBar.setOrientation (self, Qt.Orientation orientation)
  1. QToolBar.setToolButtonStyle (self, Qt.ToolButtonStyle toolButtonStyle)

这种方法也是一个Qt槽与C + +的签名void setToolButtonStyle(Qt::ToolButtonStyle)

  1. QAction QToolBar.toggleViewAction (self)

[

返回一个可用于显示或隐藏该工具栏可检查的动作。

该操作的文本设置为工具栏的窗口标题。

]($docs-qaction.html)

See also QAction.textQWidget.windowTitle

  1. Qt.ToolButtonStyle QToolBar.toolButtonStyle (self)

  1. QWidget QToolBar.widgetForAction (self, QAction action)

[

返回与指定相关的部件action

这个函数中引入了Qt 4.2中。

]($docs-qwidget.html)

See also addWidget( ) 。


Qt Signal Documentation

  1. void actionTriggered (QAction *)

这是该信号的默认超载。

当在这个工具栏的作用是触发这个信号被发射。发生这种情况时按下的动作的工具按钮时,或当动作被触发在工具栏以外的其他方式。该参数保存在触发action

  1. void allowedAreasChanged (Qt::ToolBarAreas)

这是该信号的默认超载。

当允许的区域为工具栏的集合更改这个信号被发射。在该工具条可以定位在新的区域被指定allowedAreas

See also allowedAreas

  1. void iconSizeChanged (const QSize&)

这是该信号的默认超载。

当图标大小改变这个信号被发射。该iconSize参数保存工具栏上的新图标的大小。

See also iconSizeQMainWindow.iconSize

  1. void movableChanged (bool)

这是该信号的默认超载。

当工具栏变成可移动的或固定的这个信号被发射。如果工具栏可以移动,movable为True,否则为False 。

See also movable

  1. void orientationChanged (Qt::Orientation)

这是该信号的默认超载。

这个信号被发射时的工具栏上的变化的方向。新的方向被指定的orientation给出。

See also orientation

  1. void toolButtonStyleChanged (Qt::ToolButtonStyle)

这是该信号的默认超载。

当工具按钮样式改变这个信号被发射。该toolButtonStyle参数保存工具栏的新工具按钮样式。

See also toolButtonStyleQMainWindow.toolButtonStyle

  1. void topLevelChanged (bool)

这是该信号的默认超载。

这个信号被发射时的floating属性更改。该topLevel参数为True时,如果工具栏现在是浮动的,否则它是假的。

此功能被引入Qt的4.6 。

See also isWindow( ) 。

  1. void visibilityChanged (bool)

这是该信号的默认超载。

当工具栏变成这个信号被发射visible(或不可见) 。这种情况发生在小部件隐藏或显示。

此功能被引入Qt的4.7 。