Qt Jambi Home

com.trolltech.qt.gui
Class QTabBar

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.QTabBar
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QTabBar
extends QWidget

The QTabBar class provides a tab bar, e.g. for use in tabbed dialogs.

QTabBar is straightforward to use; it draws the tabs using one of the predefined shapes, and emits a signal when a tab is selected. It can be subclassed to tailor the look and feel. Qt also provides a ready-made QTabWidget.

Each tab has a tabText, an optional tabIcon, an optional tabToolTip, optional tabWhatsThis and optional tabData. The tabs's attributes can be changed with setTabText, setTabIcon, setTabToolTip, setTabWhatsThis and setTabData. Each tabs can be enabled or disabled individually with setTabEnabled.

Each tab can display text in a distinct color. The current text color for a tab can be found with the tabTextColor function. Set the text color for a particular tab with setTabTextColor.

Tabs are added using addTab, or inserted at particular positions using insertTab. The total number of tabs is given by count. Tabs can be removed from the tab bar with removeTab. Combining removeTab and insertTab allows you to move tabs to different positions.

The shape property defines the tabs' appearance. The choice of shape is a matter of taste, although tab dialogs (for preferences and similar) invariably use RoundedNorth. Tab controls in windows other than dialogs almost always use either RoundedSouth or TriangularSouth. Many spreadsheets and other tab controls in which all the pages are essentially similar use TriangularSouth, whereas RoundedSouth is used mostly when the pages are different (e.g. a multi-page tool palette). The default in QTabBar is RoundedNorth.

The most important part of QTabBar's API is the currentChanged signal. This is emitted whenever the current tab changes (even at startup, when the current tab changes from 'none'). There is also a slot, setCurrentIndex, which can be used to select a tab programmatically. The function currentIndex returns the index of the current tab, count holds the number of tabs.

QTabBar creates automatic mnemonic keys in the manner of QAbstractButton; e.g. if a tab's label is "&Graphics", Alt+G becomes a shortcut key for switching to that tab.

The following virtual functions may need to be reimplemented in order to tailor the look and feel or store extra data with each tab:

For subclasses, you might also need the tabRect functions which returns the visual geometry of a single tab.

Screenshot of a Plastique style tab barA tab bar shown in the Plastique widget style.
Screenshot of a truncated Plastique tab barA truncated tab bar shown in the Plastique widget style.

See Also:
QTabWidget

Nested Class Summary
static class QTabBar.Shape
          This enum type lists the built-in shapes supported by QTabBar.
 
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<java.lang.Integer> currentChanged
          This signal is emitted when the tab bar's current tab changes.
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QTabBar()
          Equivalent to QTabBar(0).
QTabBar(QWidget parent)
          Creates a new tab bar with the given parent.
 
Method Summary
 int addTab(QIcon icon, java.lang.String text)
          Adds a new tab with icon icon and text text.
 int addTab(java.lang.String text)
          Adds a new tab with text text.
protected  void changeEvent(QEvent arg__1)
          

This event handler can be reimplemented to handle state changes.

 int count()
          Returns the number of tabs in the tab bar.
 int currentIndex()
          Returns the index of the tab bar's visible tab.
 boolean drawBase()
          Returns defines whether or not tab bar should draw its base..
 Qt.TextElideMode elideMode()
          Returns how to elide text in the tab bar.
 boolean event(QEvent arg__1)
          

This is the main event handler; it handles event arg__1.

static QTabBar fromNativePointer(QNativePointer nativePointer)
          This function returns the QTabBar instance pointed to by nativePointer
 QSize iconSize()
          Returns The size for icons in the tab bar.
 void initStyleOption(QStyleOptionTab option, int tabIndex)
          Initialize option with the values from the tab at tabIndex.
 int insertTab(int index, QIcon icon, java.lang.String text)
          Inserts a new tab with icon icon and text text at position index.
 int insertTab(int index, java.lang.String text)
          Inserts a new tab with text text at position index.
 boolean isTabEnabled(int index)
          Returns true if the tab at position index is enabled; otherwise returns false.
protected  void keyPressEvent(QKeyEvent arg__1)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive key press events for the widget.

 QSize minimumSizeHint()
          

Returns the recommended minimum size for the widget.

protected  void mouseMoveEvent(QMouseEvent arg__1)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse move events for the widget.

protected  void mousePressEvent(QMouseEvent arg__1)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget.

protected  void mouseReleaseEvent(QMouseEvent arg__1)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse release events for the widget.

protected  void paintEvent(QPaintEvent arg__1)
          

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

 void removeTab(int index)
          Removes the tab at position index.
protected  void resizeEvent(QResizeEvent arg__1)
          

This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter.

 void setCurrentIndex(int index)
          Sets the index of the tab bar's visible tab to index.
 void setDrawBase(boolean drawTheBase)
          Sets defines whether or not tab bar should draw its base.
 void setElideMode(Qt.TextElideMode arg__1)
          Sets how to elide text in the tab bar to arg__1.
 void setIconSize(QSize size)
          Sets The size for icons in the tab bar to size.
 void setShape(QTabBar.Shape shape)
          Sets the shape of the tabs in the tab bar to shape.
 void setTabData(int index, java.lang.Object data)
          Sets the data of the tab at position index to data.
 void setTabEnabled(int index, boolean arg__2)
          If arg__2 is true then the tab at position index is enabled; otherwise the item at position index is disabled.
 void setTabIcon(int index, QIcon icon)
          Sets the icon of the tab at position index to icon.
 void setTabText(int index, java.lang.String text)
          Sets the text of the tab at position index to text.
 void setTabTextColor(int index, QColor color)
          Sets the color of the text in the tab with the given index to the specified color.
 void setTabToolTip(int index, java.lang.String tip)
          Sets the tool tip of the tab at position index to tip.
 void setTabWhatsThis(int index, java.lang.String text)
          Sets the What's This help text of the tab at position index to text.
 void setUsesScrollButtons(boolean useButtons)
          Sets Whether or not a tab bar should use buttons to scroll tabs when it has many tabs.
 QTabBar.Shape shape()
          Returns the shape of the tabs in the tab bar.
protected  void showEvent(QShowEvent arg__1)
          

This event handler can be reimplemented in a subclass to receive widget show events which are passed in the arg__1 parameter.

 QSize sizeHint()
          

Returns the recommended size for the widget.

 int tabAt(QPoint pos)
          Returns the index of the tab that covers pos or -1 if no tab covers pos;
 java.lang.Object tabData(int index)
          Returns the datad of the tab at position index, or a null variant if index is out of range.
 QIcon tabIcon(int index)
          Returns the icon of the tab at position index, or a null icon if index is out of range.
protected  void tabInserted(int index)
          This virtual handler is called after a new tab was added or inserted at position index.
protected  void tabLayoutChange()
          This virtual handler is called whenever the tab layout changes.
 QRect tabRect(int index)
          Returns the visual rectangle of the of the tab at position index, or a null rectangle if index is out of range.
protected  void tabRemoved(int index)
          This virtual handler is called after a tab was removed from position index.
protected  QSize tabSizeHint(int index)
          Returns the size hint for the tab at position index.
 java.lang.String tabText(int index)
          Returns the text of the tab at position index, or an empty string if index is out of range.
 QColor tabTextColor(int index)
          Returns the text color of the tab with the given index, or a invalid color if index is out of range.
 java.lang.String tabToolTip(int index)
          Returns the tool tip of the tab at position index, or an empty string if index is out of range.
 java.lang.String tabWhatsThis(int index)
          Returns the What's This help text of the tab at position index, or an empty string if index is out of range.
 boolean usesScrollButtons()
          Returns Whether or not a tab bar should use buttons to scroll tabs when it has many tabs..
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, 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, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseDoubleClickEvent, mouseGrabber, 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, showFullScreen, showMaximized, showMinimized, showNormal, size, 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, childEvent, 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

currentChanged

public final QSignalEmitter.Signal1<java.lang.Integer> currentChanged

This signal is emitted when the tab bar's current tab changes. The new current has the given index.

Compatible Slot Signatures:
void mySlot(int index)
void mySlot()

Constructor Detail

QTabBar

public QTabBar()

Equivalent to QTabBar(0).


QTabBar

public QTabBar(QWidget parent)

Creates a new tab bar with the given parent.

Method Detail

addTab

public final int addTab(QIcon icon,
                        java.lang.String text)

Adds a new tab with icon icon and text text. Returns the new tab's index.


addTab

public final int addTab(java.lang.String text)

Adds a new tab with text text. Returns the new tab's index.


count

public final int count()

Returns the number of tabs in the tab bar.


currentIndex

public final int currentIndex()

Returns the index of the tab bar's visible tab.

See Also:
setCurrentIndex

drawBase

public final boolean drawBase()

Returns defines whether or not tab bar should draw its base..

If true then QTabBar draws a base in relation to the styles overlab. Otherwise only the tabs are drawn.

See Also:
setDrawBase, QStyle::pixelMetric, QStyle::PM_TabBarBaseOverlap, QStyleOptionTabBarBase

elideMode

public final Qt.TextElideMode elideMode()

Returns how to elide text in the tab bar.

This property controls how items are elided when there is not enough space to show them for a given tab bar size.

By default the value is style dependent.

See Also:
setElideMode, QTabWidget::elideMode, usesScrollButtons, QStyle::SH_TabBar_ElideMode

iconSize

public final QSize iconSize()

Returns The size for icons in the tab bar.

The default value is style-dependent. iconSize is a maximum size; icons that are smaller are not scaled up.

See Also:
setIconSize, QTabWidget::iconSize

insertTab

public final int insertTab(int index,
                           java.lang.String text)

Inserts a new tab with text text at position index. If index is out of range, the new tab is appened. Returns the new tab's index.


insertTab

public final int insertTab(int index,
                           QIcon icon,
                           java.lang.String text)

Inserts a new tab with icon icon and text text at position index. If index is out of range, the new tab is appended. Returns the new tab's index.

If the QTabBar was empty before this function is called, the inserted tab becomes the current tab.

Inserting a new tab at an index less than or equal to the current index will increment the current index, but keep the current tab.


isTabEnabled

public final boolean isTabEnabled(int index)

Returns true if the tab at position index is enabled; otherwise returns false.


removeTab

public final void removeTab(int index)

Removes the tab at position index.


setCurrentIndex

public final void setCurrentIndex(int index)

Sets the index of the tab bar's visible tab to index.

See Also:
currentIndex

setDrawBase

public final void setDrawBase(boolean drawTheBase)

Sets defines whether or not tab bar should draw its base. to drawTheBase.

If true then QTabBar draws a base in relation to the styles overlab. Otherwise only the tabs are drawn.

See Also:
drawBase, QStyle::pixelMetric, QStyle::PM_TabBarBaseOverlap, QStyleOptionTabBarBase

setElideMode

public final void setElideMode(Qt.TextElideMode arg__1)

Sets how to elide text in the tab bar to arg__1.

This property controls how items are elided when there is not enough space to show them for a given tab bar size.

By default the value is style dependent.

See Also:
QTabWidget::elideMode, usesScrollButtons, QStyle::SH_TabBar_ElideMode

setIconSize

public final void setIconSize(QSize size)

Sets The size for icons in the tab bar to size.

The default value is style-dependent. iconSize is a maximum size; icons that are smaller are not scaled up.

See Also:
QTabWidget::iconSize

setShape

public final void setShape(QTabBar.Shape shape)

Sets the shape of the tabs in the tab bar to shape.

Possible values for this property are described by the Shape enum.

See Also:
shape

setTabData

public final void setTabData(int index,
                             java.lang.Object data)

Sets the data of the tab at position index to data.

See Also:
tabData

setTabEnabled

public final void setTabEnabled(int index,
                                boolean arg__2)

If arg__2 is true then the tab at position index is enabled; otherwise the item at position index is disabled.

See Also:
isTabEnabled

setTabIcon

public final void setTabIcon(int index,
                             QIcon icon)

Sets the icon of the tab at position index to icon.

See Also:
tabIcon

setTabText

public final void setTabText(int index,
                             java.lang.String text)

Sets the text of the tab at position index to text.

See Also:
tabText

setTabTextColor

public final void setTabTextColor(int index,
                                  QColor color)

Sets the color of the text in the tab with the given index to the specified color.

If an invalid color is specified, the tab will use the QTabBar foreground role instead.

See Also:
tabTextColor

setTabToolTip

public final void setTabToolTip(int index,
                                java.lang.String tip)

Sets the tool tip of the tab at position index to tip.

See Also:
tabToolTip

setTabWhatsThis

public final void setTabWhatsThis(int index,
                                  java.lang.String text)

Sets the What's This help text of the tab at position index to text.

See Also:
tabWhatsThis

setUsesScrollButtons

public final void setUsesScrollButtons(boolean useButtons)

Sets Whether or not a tab bar should use buttons to scroll tabs when it has many tabs. to useButtons.

When there are too many tabs in a tab bar for its size, the tab bar can either choose to expand it's size or to add buttons that allow you to scroll through the tabs.

By default the value is style dependant.

See Also:
elideMode, QTabWidget::usesScrollButtons, QStyle::SH_TabBar_PreferNoArrows

shape

public final QTabBar.Shape shape()

Returns the shape of the tabs in the tab bar.

Possible values for this property are described by the Shape enum.

See Also:
setShape

tabAt

public final int tabAt(QPoint pos)

Returns the index of the tab that covers pos or -1 if no tab covers pos;


tabData

public final java.lang.Object tabData(int index)

Returns the datad of the tab at position index, or a null variant if index is out of range.

See Also:
setTabData

tabIcon

public final QIcon tabIcon(int index)

Returns the icon of the tab at position index, or a null icon if index is out of range.

See Also:
setTabIcon

tabRect

public final QRect tabRect(int index)

Returns the visual rectangle of the of the tab at position index, or a null rectangle if index is out of range.


tabText

public final java.lang.String tabText(int index)

Returns the text of the tab at position index, or an empty string if index is out of range.

See Also:
setTabText

tabTextColor

public final QColor tabTextColor(int index)

Returns the text color of the tab with the given index, or a invalid color if index is out of range.

See Also:
setTabTextColor

tabToolTip

public final java.lang.String tabToolTip(int index)

Returns the tool tip of the tab at position index, or an empty string if index is out of range.

See Also:
setTabToolTip

tabWhatsThis

public final java.lang.String tabWhatsThis(int index)

Returns the What's This help text of the tab at position index, or an empty string if index is out of range.

See Also:
setTabWhatsThis

usesScrollButtons

public final boolean usesScrollButtons()

Returns Whether or not a tab bar should use buttons to scroll tabs when it has many tabs..

When there are too many tabs in a tab bar for its size, the tab bar can either choose to expand it's size or to add buttons that allow you to scroll through the tabs.

By default the value is style dependant.

See Also:
setUsesScrollButtons, elideMode, QTabWidget::usesScrollButtons, QStyle::SH_TabBar_PreferNoArrows

changeEvent

protected void changeEvent(QEvent arg__1)

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.

Overrides:
changeEvent in class QWidget

event

public boolean event(QEvent arg__1)

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.

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

keyPressEvent

protected void keyPressEvent(QKeyEvent arg__1)

This event handler, for event arg__1, can be reimplemented in a subclass to receive key press events for the widget.

A widget must call setFocusPolicy to accept focus initially and have focus in order to receive a key press event.

If you reimplement this handler, it is very important that you ignore() the event if you do not understand it, so that the widget's parent can interpret it.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.

Overrides:
keyPressEvent in class QWidget
See Also:
keyReleaseEvent, QKeyEvent::ignore, setFocusPolicy, focusInEvent, focusOutEvent, event, QKeyEvent, Tetrix Example

minimumSizeHint

public QSize minimumSizeHint()

Returns the recommended minimum size for the widget.

If the value of this property is an invalid size, no minimum size is recommended.

The default implementation of minimumSizeHint returns an invalid size if there is no layout for this widget, and returns the layout's minimum size otherwise. Most built-in widgets reimplement minimumSizeHint.

QLayout will never resize a widget to a size smaller than the minimum size hint unless minimumSize is set or the size policy is set to QSizePolicy::Ignore. If minimumSize is set, the minimum size hint will be ignored.

Overrides:
minimumSizeHint in class QWidget
See Also:
QSize::isValid, resize, setMinimumSize, sizePolicy

mouseMoveEvent

protected void mouseMoveEvent(QMouseEvent arg__1)

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse move events for the widget.

If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not Qt.

Overrides:
mouseMoveEvent in class QWidget
See Also:
setMouseTracking, mousePressEvent, mouseReleaseEvent, mouseDoubleClickEvent, event, QMouseEvent, Example

mousePressEvent

protected void mousePressEvent(QMouseEvent arg__1)

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent the mouseReleaseEvent may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

Overrides:
mousePressEvent in class QWidget
See Also:
mouseReleaseEvent, mouseDoubleClickEvent, mouseMoveEvent, event, QMouseEvent, Example

mouseReleaseEvent

protected void mouseReleaseEvent(QMouseEvent arg__1)

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse release events for the widget.

Overrides:
mouseReleaseEvent in class QWidget
See Also:
mousePressEvent, mouseDoubleClickEvent, mouseMoveEvent, event, QMouseEvent, Example

paintEvent

protected void paintEvent(QPaintEvent arg__1)

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.

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

resizeEvent

protected void resizeEvent(QResizeEvent arg__1)

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.

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

showEvent

protected void showEvent(QShowEvent arg__1)

This event handler can be reimplemented in a subclass to receive widget show events which are passed in the arg__1 parameter.

Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of windows are delivered afterwards.

Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible.

Overrides:
showEvent in class QWidget
See Also:
visible, event, QShowEvent

sizeHint

public QSize sizeHint()

Returns the recommended size for the widget.

If the value of this property is an invalid size, no size is recommended.

The default implementation of sizeHint returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.

Overrides:
sizeHint in class QWidget
See Also:
QSize::isValid, minimumSizeHint, sizePolicy, setMinimumSize, updateGeometry

tabInserted

protected void tabInserted(int index)

This virtual handler is called after a new tab was added or inserted at position index.

See Also:
tabRemoved

tabLayoutChange

protected void tabLayoutChange()

This virtual handler is called whenever the tab layout changes.

See Also:
tabRect

tabRemoved

protected void tabRemoved(int index)

This virtual handler is called after a tab was removed from position index.

See Also:
tabInserted

tabSizeHint

protected QSize tabSizeHint(int index)

Returns the size hint for the tab at position index.


fromNativePointer

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

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

initStyleOption

public final void initStyleOption(QStyleOptionTab option,
                                  int tabIndex)
Initialize option with the values from the tab at tabIndex. This method is useful for subclasses when they need a QStyleOptionTab or QStyleOptionTabV2, but don't want to fill in all the information themselves. This function will check the version of the QStyleOptionTab and fill in the additional values for a QStyleOptionTabV2.


Qt Jambi Home