com.trolltech.qt.gui
Class QToolBar

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QToolBar
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QToolBar
extends QWidget

The QToolBar class provides a movable panel that contains a set of controls.

Toolbar buttons are added by adding actions, using addAction or insertAction. Groups of buttons can be separated using addSeparator or insertSeparator. If a toolbar button is not appropriate, a widget can be inserted instead using addWidget or insertWidget; examples of suitable widgets are QSpinBox, QDoubleSpinBox, and QComboBox. When a toolbar button is pressed it emits the actionTriggered signal.

A toolbar can be fixed in place in a particular area (e.g. at the top of the window), or it can be movable (isMovable) between toolbar areas; see allowedAreas and isAreaAllowed.

When a toolbar is resized in such a way that it is too small to show all the items it contains, an extension button will appear as the last item in the toolbar. Pressing the extension button will pop up a menu containing the items that does not currently fit in the toolbar.

When a QToolBar is not a child of a QMainWindow, it looses the ability to populate the extension pop up with widgets added to the toolbar using addWidget. Please use widget actions created by inheriting QWidgetAction and implementing QWidgetAction::createWidget() instead. This is a known issue which will be fixed in a future release.

See Also:
QToolButton, QMenu, QAction, Application Example

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
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<QAction> actionTriggered
          This signal is emitted when an action in this toolbar is triggered.
 QSignalEmitter.Signal1<Qt.ToolBarAreas> allowedAreasChanged
          This signal is emitted when the collection of allowed areas for the toolbar is changed.
 QSignalEmitter.Signal1<QSize> iconSizeChanged
          This signal is emitted when the icon size is changed.
 QSignalEmitter.Signal1<java.lang.Boolean> movableChanged
          This signal is emitted when the toolbar becomes movable or fixed.
 QSignalEmitter.Signal1<Qt.Orientation> orientationChanged
          This signal is emitted when the orientation of the toolbar changes.
 QSignalEmitter.Signal1<Qt.ToolButtonStyle> toolButtonStyleChanged
          This signal is emitted when the tool button style is changed.
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QToolBar()
          Equivalent to QToolBar(0).
QToolBar(QWidget parent)
          Constructs a QToolBar with the given parent.
QToolBar(java.lang.String title)
          Equivalent to QToolBar(title, 0).
QToolBar(java.lang.String title, QWidget parent)
          Constructs a QToolBar with the given parent.
 
Method Summary
 QAction actionAt(int x, int y)
          Returns the action at the point x, y.
 QAction actionAt(QPoint p)
          Returns the action at point p.
protected  void actionEvent(QActionEvent event)
          This function is reimplemented for internal reasons.
 QRect actionGeometry(QAction action)
          This method is used internally by Qt Jambi.
 QAction addAction(QIcon icon, java.lang.String text)
          Creates a new action with the given icon and text.
 QAction addAction(QIcon icon, java.lang.String text, java.lang.Object receiver, java.lang.String method)
          Creates a new action with the icon icon and text text.
 QAction addAction(QIcon icon, java.lang.String text, QSignalEmitter.AbstractSignal signal)
          Creates a new action with the icon icon and text text.
 QAction addAction(java.lang.String text)
          Creates a new action with the given text.
 QAction addAction(java.lang.String text, java.lang.Object receiver, java.lang.String method)
          Creates a new action with text text.
 QAction addAction(java.lang.String text, QSignalEmitter.AbstractSignal signal)
          Creates a new action with text text.
 QAction addSeparator()
          Adds a separator to the end of the toolbar.
 QAction addWidget(QWidget widget)
          Adds the given widget to the toolbar as the toolbar's last item.
 Qt.ToolBarAreas allowedAreas()
          Returns areas where the toolbar may be placed.
protected  void changeEvent(QEvent event)
          This function is reimplemented for internal reasons.
protected  void childEvent(QChildEvent event)
          This function is reimplemented for internal reasons.
 void clear()
          Removes all actions from the toolbar.
 boolean event(QEvent event)
          This function is reimplemented for internal reasons.
static QToolBar fromNativePointer(QNativePointer nativePointer)
          This function returns the QToolBar instance pointed to by nativePointer
 QSize iconSize()
          Returns size of icons in the toolbar..
protected  void initStyleOption(QStyleOptionToolBar option)
          Initialize option with the values from the menu bar and information from action.
 QAction insertSeparator(QAction before)
          Inserts a separator into the toolbar in front of the toolbar item associated with the before action.
 QAction insertWidget(QAction before, QWidget widget)
          Inserts the given widget in front of the toolbar item associated with the before action.
 boolean isAreaAllowed(Qt.ToolBarArea area)
          Returns true if this toolbar is dockable in the given area; otherwise returns false.
 boolean isFloatable()
          Returns whether the toolbar can be dragged and dropped as an independent window..
 boolean isFloating()
          Returns whether the toolbar is an independent window..
 boolean isMovable()
          Returns whether the user can move the toolbar within the toolbar area, or between toolbar areas.
 Qt.Orientation orientation()
          Returns orientation of the toolbar.
protected  void paintEvent(QPaintEvent event)
          This function is reimplemented for internal reasons.
protected  void resizeEvent(QResizeEvent event)
          This function is reimplemented for internal reasons.
 void setAllowedAreas(Qt.ToolBarArea... areas)
          Sets areas where the toolbar may be placed to areas.
 void setAllowedAreas(Qt.ToolBarAreas areas)
          Sets areas where the toolbar may be placed to areas.
 void setFloatable(boolean floatable)
          Sets whether the toolbar can be dragged and dropped as an independent window.
 void setIconSize(QSize iconSize)
          Sets size of icons in the toolbar.
 void setMovable(boolean movable)
          Sets whether the user can move the toolbar within the toolbar area, or between toolbar areas to movable.
 void setOrientation(Qt.Orientation orientation)
          Sets orientation of the toolbar to orientation.
 void setToolButtonStyle(Qt.ToolButtonStyle toolButtonStyle)
          Sets the style of toolbar buttons to toolButtonStyle.
 QAction toggleViewAction()
          Returns a checkable action that can be used to show or hide this toolbar.
 Qt.ToolButtonStyle toolButtonStyle()
          Returns the style of toolbar buttons.
 QWidget widgetForAction(QAction action)
          Returns the widget associated with the specified action.
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, 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

actionTriggered

public final QSignalEmitter.Signal1<QAction> actionTriggered

This signal is emitted when an action in this toolbar is triggered. This happens when the action's tool button is pressed, or when the action is triggered in some other way outside the tool bar. The parameter holds the triggered action.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QAction action)
void mySlot()


allowedAreasChanged

public final QSignalEmitter.Signal1<Qt.ToolBarAreas> allowedAreasChanged

This signal is emitted when the collection of allowed areas for the toolbar is changed. The new areas in which the toolbar can be positioned are specified by allowedAreas.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.Qt.ToolBarAreas allowedAreas)
void mySlot()
See Also:
allowedAreas


iconSizeChanged

public final QSignalEmitter.Signal1<QSize> iconSizeChanged

This signal is emitted when the icon size is changed. The iconSize parameter holds the toolbar's new icon size.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.QSize iconSize)
void mySlot()
See Also:
iconSize, QMainWindow::iconSize


movableChanged

public final QSignalEmitter.Signal1<java.lang.Boolean> movableChanged

This signal is emitted when the toolbar becomes movable or fixed. If the toolbar can be moved, movable is true; otherwise it is false.

Compatible Slot Signatures:
void mySlot(boolean movable)
void mySlot()
See Also:
movable


orientationChanged

public final QSignalEmitter.Signal1<Qt.Orientation> orientationChanged

This signal is emitted when the orientation of the toolbar changes. The new orientation is specified by the orientation given.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.Qt.Orientation orientation)
void mySlot()
See Also:
orientation


toolButtonStyleChanged

public final QSignalEmitter.Signal1<Qt.ToolButtonStyle> toolButtonStyleChanged

This signal is emitted when the tool button style is changed. The toolButtonStyle parameter holds the toolbar's new tool button style.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.Qt.ToolButtonStyle toolButtonStyle)
void mySlot()
See Also:
toolButtonStyle, QMainWindow::toolButtonStyle

Constructor Detail

QToolBar

public QToolBar(java.lang.String title)

Equivalent to QToolBar(title, 0).


QToolBar

public QToolBar(java.lang.String title,
                QWidget parent)

Constructs a QToolBar with the given parent.

The given window title identifies the toolbar and is shown in the context menu provided by QMainWindow.

See Also:
setWindowTitle

QToolBar

public QToolBar()

Equivalent to QToolBar(0).


QToolBar

public QToolBar(QWidget parent)

Constructs a QToolBar with the given parent.

Method Detail

actionAt

public final QAction actionAt(int x,
                              int y)

Returns the action at the point x, y. This function returns zero if no action was found.


actionAt

public final QAction actionAt(QPoint p)

Returns the action at point p. This function returns zero if no action was found.

See Also:
QWidget::childAt

actionGeometry

public final QRect actionGeometry(QAction action)

This method is used internally by Qt Jambi. Do not use it in your applications.


addAction

public final QAction addAction(QIcon icon,
                               java.lang.String text)

Creates a new action with the given icon and text. This action is added to the end of the toolbar.


addAction

public final QAction addAction(java.lang.String text)

Creates a new action with the given text. This action is added to the end of the toolbar.


addSeparator

public final QAction addSeparator()

Adds a separator to the end of the toolbar.

See Also:
insertSeparator

addWidget

public final QAction addWidget(QWidget widget)

Adds the given widget to the toolbar as the toolbar's last item.

If you add a QToolButton with this method, the tools bar's Qt::ToolButtonStyle will not be respected.

Note: You should use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.

See Also:
insertWidget

allowedAreas

public final Qt.ToolBarAreas allowedAreas()

Returns areas where the toolbar may be placed.

The default is Qt::AllToolBarAreas.

This property only makes sense if the toolbar is in a QMainWindow.

See Also:
setAllowedAreas, movable

clear

public final void clear()

Removes all actions from the toolbar.

See Also:
removeAction

iconSize

public final QSize iconSize()

Returns size of icons in the toolbar..

The default size is determined by the application's style and is derived from the QStyle::PM_ToolBarIconSize pixel metric. It is the maximum size an icon can have. Icons of smaller size will not be scaled up.

See Also:
setIconSize

insertSeparator

public final QAction insertSeparator(QAction before)

Inserts a separator into the toolbar in front of the toolbar item associated with the before action.

See Also:
addSeparator

insertWidget

public final QAction insertWidget(QAction before,
                                  QWidget widget)

Inserts the given widget in front of the toolbar item associated with the before action.

Note: You should use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.

See Also:
addWidget

isAreaAllowed

public final boolean isAreaAllowed(Qt.ToolBarArea area)

Returns true if this toolbar is dockable in the given area; otherwise returns false.


isFloatable

public final boolean isFloatable()

Returns whether the toolbar can be dragged and dropped as an independent window..

The default is true.


isFloating

public final boolean isFloating()

Returns whether the toolbar is an independent window..

See Also:
QWidget::isWindow

isMovable

public final boolean isMovable()

Returns whether the user can move the toolbar within the toolbar area, or between toolbar areas.

By default, this property is true.

This property only makes sense if the toolbar is in a QMainWindow.

See Also:
allowedAreas

orientation

public final Qt.Orientation orientation()

Returns orientation of the toolbar.

The default is Qt::Horizontal.

This function should not be used when the toolbar is managed by QMainWindow. You can use QMainWindow::addToolBar() or QMainWindow::insertToolBar() if you wish to move a toolbar (that is already added to a main window) to another Qt::ToolBarArea.

See Also:
setOrientation

setAllowedAreas

public final void setAllowedAreas(Qt.ToolBarArea... areas)

Sets areas where the toolbar may be placed to areas.

The default is Qt::AllToolBarAreas.

This property only makes sense if the toolbar is in a QMainWindow.

See Also:
allowedAreas, movable

setAllowedAreas

public final void setAllowedAreas(Qt.ToolBarAreas areas)

Sets areas where the toolbar may be placed to areas.

The default is Qt::AllToolBarAreas.

This property only makes sense if the toolbar is in a QMainWindow.

See Also:
allowedAreas, movable

setFloatable

public final void setFloatable(boolean floatable)

Sets whether the toolbar can be dragged and dropped as an independent window. to floatable.

The default is true.

See Also:
isFloatable

setIconSize

public final void setIconSize(QSize iconSize)

Sets size of icons in the toolbar. to iconSize.

The default size is determined by the application's style and is derived from the QStyle::PM_ToolBarIconSize pixel metric. It is the maximum size an icon can have. Icons of smaller size will not be scaled up.

See Also:
iconSize

setMovable

public final void setMovable(boolean movable)

Sets whether the user can move the toolbar within the toolbar area, or between toolbar areas to movable.

By default, this property is true.

This property only makes sense if the toolbar is in a QMainWindow.

See Also:
isMovable, allowedAreas

setOrientation

public final void setOrientation(Qt.Orientation orientation)

Sets orientation of the toolbar to orientation.

The default is Qt::Horizontal.

This function should not be used when the toolbar is managed by QMainWindow. You can use QMainWindow::addToolBar() or QMainWindow::insertToolBar() if you wish to move a toolbar (that is already added to a main window) to another Qt::ToolBarArea.

See Also:
orientation

setToolButtonStyle

public final void setToolButtonStyle(Qt.ToolButtonStyle toolButtonStyle)

Sets the style of toolbar buttons to toolButtonStyle.

This property defines the style of all tool buttons that are added as QActions. Note that if you add a QToolButton with the addWidget method, it will not get this button style.

The default is Qt::ToolButtonIconOnly.

See Also:
toolButtonStyle

toggleViewAction

public final QAction toggleViewAction()

Returns a checkable action that can be used to show or hide this toolbar.

The action's text is set to the toolbar's window title.

See Also:
QAction::text, QWidget::windowTitle

toolButtonStyle

public final Qt.ToolButtonStyle toolButtonStyle()

Returns the style of toolbar buttons.

This property defines the style of all tool buttons that are added as QActions. Note that if you add a QToolButton with the addWidget method, it will not get this button style.

The default is Qt::ToolButtonIconOnly.

See Also:
setToolButtonStyle

widgetForAction

public final QWidget widgetForAction(QAction action)

Returns the widget associated with the specified action.

See Also:
addWidget

actionEvent

protected void actionEvent(QActionEvent event)

This function is reimplemented for internal reasons.

Overrides:
actionEvent in class QWidget
See Also:
addAction, insertAction, removeAction, actions, QActionEvent

changeEvent

protected void changeEvent(QEvent event)

This function is reimplemented for internal reasons.

Overrides:
changeEvent in class QWidget

childEvent

protected void childEvent(QChildEvent event)

This function is reimplemented for internal reasons.

Overrides:
childEvent in class QObject
See Also:
event

event

public boolean event(QEvent event)

This function is reimplemented for internal reasons.

Overrides:
event in class QWidget
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

paintEvent

protected void paintEvent(QPaintEvent event)

This function is reimplemented for internal reasons.

Overrides:
paintEvent in class QWidget
See Also:
event, repaint, update, QPainter, QPixmap, QPaintEvent, Analog Clock Example

resizeEvent

protected void resizeEvent(QResizeEvent event)

This function is reimplemented for internal reasons.

Overrides:
resizeEvent in class QWidget
See Also:
moveEvent, event, resize, QResizeEvent, paintEvent, Example

fromNativePointer

public static QToolBar fromNativePointer(QNativePointer nativePointer)
This function returns the QToolBar instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

initStyleOption

protected final void initStyleOption(QStyleOptionToolBar option)
Initialize option with the values from the menu bar and information from action. This method is useful for subclasses when they need a QStyleOptionMenuItem, but don't want to fill in all the information themselves.


addAction

public final QAction addAction(QIcon icon,
                               java.lang.String text,
                               java.lang.Object receiver,
                               java.lang.String method)
Creates a new action with the icon icon and text text. This action is added to the end of the toolbar. The action's QAction.triggered() signal is connected to method in receiver.

Finally, it returns the created action.


addAction

public final QAction addAction(QIcon icon,
                               java.lang.String text,
                               QSignalEmitter.AbstractSignal signal)
Creates a new action with the icon icon and text text. This action is added to the end of the toolbar. The action is triggered by signal. The created QAction is returned.


addAction

public final QAction addAction(java.lang.String text,
                               java.lang.Object receiver,
                               java.lang.String method)
Creates a new action with text text. This action is added to the end of the toolbar. The action's QAction.triggered() signal is connected to method in receiver. The created action is returned.


addAction

public final QAction addAction(java.lang.String text,
                               QSignalEmitter.AbstractSignal signal)
Creates a new action with text text. It is connected to signal and returned.