|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QToolBar
public class QToolBar
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.
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 event handler is called with the given arg__1 whenever the widget's actions are changed. |
QRect |
actionGeometry(QAction action)
|
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 event handler can be reimplemented to handle state changes. |
protected void |
childEvent(QChildEvent event)
This event handler can be reimplemented in a subclass to receive child events. |
void |
clear()
Removes all actions from the toolbar. |
boolean |
event(QEvent event)
This is the main event handler; it handles event arg__1. |
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 event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter. |
protected void |
resizeEvent(QResizeEvent event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter. |
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.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 |
---|
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.
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.
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.
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.
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.
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.
Constructor Detail |
---|
public QToolBar(java.lang.String title)
Equivalent to QToolBar(title, 0).
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.
public QToolBar()
Equivalent to QToolBar(0).
public QToolBar(QWidget parent)
Constructs a QToolBar with the given parent.
Method Detail |
---|
public final QAction actionAt(QPoint p)
Returns the action at point p. This function returns zero if no action was found.
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.
public final QRect actionGeometry(QAction action)
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.
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.
public final QAction addSeparator()
Adds a separator to the end of the toolbar.
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.
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.
movable
public final void clear()
Removes all actions from the toolbar.
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.
public final QAction insertSeparator(QAction before)
Inserts a separator into the toolbar in front of the toolbar item associated with the before action.
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.
public final boolean isAreaAllowed(Qt.ToolBarArea area)
Returns true if this toolbar is dockable in the given area; otherwise returns false.
public final boolean isFloatable()
Returns whether the toolbar can be dragged and dropped as an independent window..
The default is true.
public final boolean isFloating()
Returns whether the toolbar is an independent window..
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.
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.
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.
movable
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.
movable
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.
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.
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.
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.
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.
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.
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.
public final QWidget widgetForAction(QAction action)
Returns the widget associated with the specified action.
protected void actionEvent(QActionEvent event)
This event handler is called with the given arg__1 whenever the widget's actions are changed.
actionEvent
in class QWidget
protected void changeEvent(QEvent event)
This event handler can be reimplemented to handle state changes.
The state being changed in this event can be retrieved through event arg__1.
Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange.
changeEvent
in class QWidget
protected void childEvent(QChildEvent event)
This event handler can be reimplemented in a subclass to receive child events. The event is passed in the arg__1 parameter.
QEvent::ChildAdded and QEvent::ChildRemoved events are sent to objects when children are added or removed. In both cases you can only rely on the child being a QObject, or if isWidgetType returns true, a QWidget. (This is because, in the ChildAdded case, the child is not yet fully constructed, and in the ChildRemoved case it might have been destructed already).
QEvent::ChildPolished events are sent to widgets when children are polished, or when polished children are added. If you receive a child polished event, the child's construction is usually completed.
For every child widget, you receive one ChildAdded event, zero or more ChildPolished events, and one ChildRemoved event.
The ChildPolished event is omitted if a child is removed immediately after it is added. If a child is polished several times during construction and destruction, you may receive several child polished events for the same child, each time with a different virtual table.
childEvent
in class QObject
public boolean event(QEvent event)
This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.
Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.
Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.
This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.
event
in class QWidget
protected void paintEvent(QPaintEvent event)
This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.
Qt also tries to speed up painting by merging multiple paint events into one. When update is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint does not permit this optimization, so we suggest using update whenever possible.
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.
The background can be set using setBackgroundRole and setPalette.
From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.
Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:
... extern void qt_x11_set_global_double_buffer(bool); qt_x11_set_global_double_buffer(false); ...
Note: In general, one should refrain from calling update or repaint inside of paintEvent. For example, calling update or repaint on children inside a paintEvent results in undefined behavior; the child may or may not get a paint event.
paintEvent
in class QWidget
protected void resizeEvent(QResizeEvent event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter. When resizeEvent is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
resizeEvent
in class QWidget
Example
public static QToolBar fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.protected final void initStyleOption(QStyleOptionToolBar option)
public final QAction addAction(QIcon icon, java.lang.String text, java.lang.Object receiver, java.lang.String method)
Finally, it returns the created action.
public final QAction addAction(QIcon icon, java.lang.String text, QSignalEmitter.AbstractSignal signal)
public final QAction addAction(java.lang.String text, java.lang.Object receiver, java.lang.String method)
public final QAction addAction(java.lang.String text, QSignalEmitter.AbstractSignal signal)
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |