Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Protected Functions | Private Functions | Properties | Friends | List of all members
QTabWidget Class Reference

The QTabWidget class provides a stack of tabbed widgets. More...

#include <qtabwidget.h>

Inheritance diagram for QTabWidget:
QWidget QObject QPaintDevice

Public Types

enum  TabPosition { North, South, West, East }
 This enum type defines where QTabWidget draws the tab row: More...
 
enum  TabShape { Rounded, Triangular }
 This enum type defines the shape of the tabs: More...
 
- Public Types inherited from QWidget
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }
 This enum describes how to render the widget when calling QWidget::render(). More...
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Public Slots

void setCurrentIndex (int index)
 
void setCurrentWidget (QWidget *widget)
 Makes widget the current widget. More...
 
- Public Slots inherited from QWidget
bool close ()
 Closes this widget. More...
 
void hide ()
 Hides the widget. More...
 
void lower ()
 Lowers the widget to the bottom of the parent widget's stack. More...
 
void raise ()
 Raises this widget to the top of the parent widget's stack. More...
 
void repaint ()
 Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More...
 
void setDisabled (bool)
 Disables widget input events if disable is true; otherwise enables input events. More...
 
void setEnabled (bool)
 
void setFocus ()
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setHidden (bool hidden)
 Convenience function, equivalent to setVisible(!hidden). More...
 
QT_MOC_COMPAT void setShown (bool shown)
 Use setVisible(shown) instead. More...
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void show ()
 Shows the widget and its child widgets. More...
 
void showFullScreen ()
 Shows the widget in full-screen mode. More...
 
void showMaximized ()
 Shows the widget maximized. More...
 
void showMinimized ()
 Shows the widget minimized, as an icon. More...
 
void showNormal ()
 Restores the widget after it has been maximized or minimized. More...
 
void update ()
 Updates the widget unless updates are disabled or the widget is hidden. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void currentChanged (int index)
 This signal is emitted whenever the current page index changes. More...
 
void tabCloseRequested (int index)
 This signal is emitted when the close button on a tab is clicked. More...
 
- Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

int addTab (QWidget *widget, const QString &)
 Adds a tab with the given page and label to the tab widget, and returns the index of the tab in the tab bar. More...
 
int addTab (QWidget *widget, const QIcon &icon, const QString &label)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds a tab with the given page, icon, and label to the tab widget, and returns the index of the tab in the tab bar. More...
 
void clear ()
 Removes all the pages, but does not delete them. More...
 
QWidgetcornerWidget (Qt::Corner corner=Qt::TopRightCorner) const
 Returns the widget shown in the corner of the tab widget or 0. More...
 
int count () const
 
int currentIndex () const
 
QWidgetcurrentWidget () const
 Returns a pointer to the page currently being displayed by the tab dialog. More...
 
bool documentMode () const
 
Qt::TextElideMode elideMode () const
 
int heightForWidth (int width) const
 Reimplemented Function More...
 
QSize iconSize () const
 
int indexOf (QWidget *widget) const
 Returns the index position of the page occupied by the widget w, or -1 if the widget cannot be found. More...
 
int insertTab (int index, QWidget *widget, const QString &)
 Inserts a tab with the given label and page into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar. More...
 
int insertTab (int index, QWidget *widget, const QIcon &icon, const QString &label)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts a tab with the given label, page, and icon into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar. More...
 
bool isMovable () const
 
bool isTabEnabled (int index) const
 Returns true if the page at position index is enabled; otherwise returns false. More...
 
QSize minimumSizeHint () const
 Returns a suitable minimum size for the tab widget. More...
 
 QTabWidget (QWidget *parent=0)
 Constructs a tabbed widget with parent parent. More...
 
void removeTab (int index)
 Removes the tab at position index from this stack of widgets. More...
 
void setCornerWidget (QWidget *w, Qt::Corner corner=Qt::TopRightCorner)
 Sets the given widget to be shown in the specified corner of the tab widget. More...
 
void setDocumentMode (bool set)
 
void setElideMode (Qt::TextElideMode)
 
void setIconSize (const QSize &size)
 
void setMovable (bool movable)
 
void setTabEnabled (int index, bool)
 If enable is true, the page at position index is enabled; otherwise the page at position index is disabled. More...
 
void setTabIcon (int index, const QIcon &icon)
 Sets the icon for the tab at position index. More...
 
void setTabPosition (TabPosition)
 
void setTabsClosable (bool closeable)
 
void setTabShape (TabShape s)
 
void setTabText (int index, const QString &)
 Defines a new label for the page at position index's tab. More...
 
void setTabToolTip (int index, const QString &tip)
 Sets the tab tool tip for the page at position index to tip. More...
 
void setTabWhatsThis (int index, const QString &text)
 Sets the What's This help text for the page at position index to text. More...
 
void setUsesScrollButtons (bool useButtons)
 
QSize sizeHint () const
 Reimplemented Function More...
 
QIcon tabIcon (int index) const
 Returns the icon for the tab on the page at position index. More...
 
TabPosition tabPosition () const
 
bool tabsClosable () const
 
TabShape tabShape () const
 
QString tabText (int index) const
 Returns the label text for the tab on the page at position index. More...
 
QString tabToolTip (int index) const
 Returns the tab tool tip for the page at position index or an empty string if no tool tip has been set. More...
 
QString tabWhatsThis (int index) const
 Returns the What's This help text for the page at position index, or an empty string if no help text has been set. More...
 
bool usesScrollButtons () const
 
QWidgetwidget (int index) const
 Returns the tab page at index position index or 0 if the index is out of range. More...
 
 ~QTabWidget ()
 Destroys the tabbed widget. More...
 
- Public Functions inherited from QWidget
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 Returns the (possibly empty) list of this widget's actions. More...
 
void activateWindow ()
 Sets the top-level widget containing this widget to be the active window. More...
 
void addAction (QAction *action)
 Appends the action action to this widget's list of actions. More...
 
void addActions (QList< QAction *> actions)
 Appends the actions actions to this widget's list of actions. More...
 
void adjustSize ()
 Adjusts the size of the widget to fit its contents. More...
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 Returns the background role of the widget. More...
 
QSize baseSize () const
 
QWidgetchildAt (int x, int y) const
 Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More...
 
QWidgetchildAt (const QPoint &p) const
 Returns the visible child widget at point p in the widget's own coordinate system. More...
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 Takes keyboard input focus from the widget. More...
 
void clearMask ()
 Removes any mask set by setMask(). More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 Returns the area inside the widget's margins. More...
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void createWinId ()
 
QCursor cursor () const
 
int devType () const
 
WId effectiveWinId () const
 Returns the effective window system identifier of the widget, i. More...
 
void ensurePolished () const
 Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More...
 
Qt::FocusPolicy focusPolicy () const
 
QWidgetfocusProxy () const
 Returns the focus proxy, or 0 if there is no focus proxy. More...
 
QWidgetfocusWidget () const
 Returns the last child of this widget that setFocus had been called on. More...
 
const QFontfont () const
 
QFontInfo fontInfo () const
 Returns the font info for the widget's current font. More...
 
QFontMetrics fontMetrics () const
 Returns the font metrics for the widget's current font. More...
 
QPalette::ColorRole foregroundRole () const
 Returns the foreground role. More...
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the widget's contents margins for left, top, right, and bottom. More...
 
HDC getDC () const
 Returns the window system handle of the widget, for low-level access. More...
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the widget to a given gesture with specific flags. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
void grabMouse (const QCursor &)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More...
 
QGraphicsEffectgraphicsEffect () const
 The graphicsEffect function returns a pointer to the widget's graphics effect. More...
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More...
 
bool hasFocus () const
 
bool hasMouseTracking () const
 
int height () const
 
QInputContextinputContext ()
 This function returns the QInputContext for this widget. More...
 
Qt::InputMethodHints inputMethodHints () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery) const
 This method is only relevant for input widgets. More...
 
void insertAction (QAction *before, QAction *action)
 Inserts the action action to this widget's list of actions, before the action before. More...
 
void insertActions (QAction *before, QList< QAction *> actions)
 Inserts the actions actions to this widget's list of actions, before the action before. More...
 
WId internalWinId () const
 Returns the window system identifier of the widget, or 0 if the widget is not created yet. More...
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More...
 
bool isEnabled () const
 
bool isEnabledTo (QWidget *) const
 Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More...
 
bool isEnabledToTLW () const
 This function is deprecated. More...
 
bool isFullScreen () const
 
bool isHidden () const
 Returns true if the widget is hidden, otherwise returns false. More...
 
bool isLeftToRight () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isRightToLeft () const
 
bool isTopLevel () const
 Use isWindow() instead. More...
 
bool isVisible () const
 
bool isVisibleTo (QWidget *) const
 Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More...
 
bool isWindow () const
 Returns true if the widget is an independent window, otherwise returns false. More...
 
bool isWindowModified () const
 
QLayoutlayout () const
 Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More...
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
Qt::HANDLE macCGHandle () const
 Returns the CoreGraphics handle of the widget. More...
 
Qt::HANDLE macQDHandle () const
 Returns the QuickDraw handle of the widget. More...
 
QPoint mapFrom (QWidget *, const QPoint &) const
 Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More...
 
QPoint mapFromGlobal (const QPoint &) const
 Translates the global screen coordinate pos to widget coordinates. More...
 
QPoint mapFromParent (const QPoint &) const
 Translates the parent widget coordinate pos to widget coordinates. More...
 
QPoint mapTo (QWidget *, const QPoint &) const
 Translates the widget coordinate pos to the coordinate system of parent. More...
 
QPoint mapToGlobal (const QPoint &) const
 Translates the widget coordinate pos to global screen coordinates. More...
 
QPoint mapToParent (const QPoint &) const
 Translates the widget coordinate pos to a coordinate in the parent widget. More...
 
QRegion mask () const
 Returns the mask currently set on a widget. More...
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
void move (int x, int y)
 This corresponds to move(QPoint(x, y)). More...
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const
 Returns the native parent for this widget, i. More...
 
QWidgetnextInFocusChain () const
 Returns the next widget in this widget's focus chain. More...
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags type)
 Sets the window flags for the widget to flags, without telling the window system. More...
 
void overrideWindowState (Qt::WindowStates state)
 
QPaintEnginepaintEngine () const
 Returns the widget's paint engine. More...
 
const QPalettepalette () const
 
QWidgetparentWidget () const
 Returns the parent of this widget, or 0 if it does not have any parent widget. More...
 
QPoint pos () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
 QWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a widget which is a child of parent, with widget flags set to f. More...
 
QRect rect () const
 
void releaseDC (HDC) const
 Releases the HDC hdc acquired by a previous call to getDC(). More...
 
void releaseKeyboard ()
 Releases the keyboard grab. More...
 
void releaseMouse ()
 Releases the mouse grab. More...
 
void releaseShortcut (int id)
 Removes the shortcut with the given id from Qt's shortcut system. More...
 
void removeAction (QAction *action)
 Removes the action action from this widget's list of actions. More...
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More...
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the widget into the painter's QPainter::device(). More...
 
void repaint (int x, int y, int w, int h)
 This version repaints a rectangle (x, y, w, h) inside the widget. More...
 
void repaint (const QRect &)
 This version repaints a rectangle rect inside the widget. More...
 
void repaint (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void resize (int w, int h)
 This corresponds to resize(QSize(w, h)). More...
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 Restores the geometry and state top-level widgets stored in the byte array geometry. More...
 
QByteArray saveGeometry () const
 Saves the current geometry and state for top-level widgets. More...
 
void scroll (int dx, int dy)
 Scrolls the widget including its children dx pixels to the right and dy downward. More...
 
void scroll (int dx, int dy, const QRect &)
 This version only scrolls r and does not move the children of the widget. More...
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More...
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole)
 Sets the background role of the widget to role. More...
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 This corresponds to setBaseSize(QSize(basew, baseh)). More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More...
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setFixedHeight (int h)
 Sets both the minimum and maximum heights of the widget to h without changing the widths. More...
 
void setFixedSize (const QSize &)
 Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More...
 
void setFixedSize (int w, int h)
 Sets the width of the widget to w and the height to h. More...
 
void setFixedWidth (int w)
 Sets both the minimum and maximum width of the widget to w without changing the heights. More...
 
void setFocus (Qt::FocusReason reason)
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *)
 Sets the widget's focus proxy to widget w. More...
 
void setFont (const QFont &)
 Use the single-argument overload instead. More...
 
void setForegroundRole (QPalette::ColorRole)
 Sets the foreground role of the widget to role. More...
 
void setGeometry (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More...
 
void setGeometry (const QRect &)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 The setGraphicsEffect function is for setting the widget's graphics effect. More...
 
void setInputContext (QInputContext *)
 This function sets the input context context on this widget. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *)
 Sets the layout manager for this widget to layout. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &)
 Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More...
 
void setMask (const QRegion &)
 Causes only the parts of the widget which overlap region to be visible. More...
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 This function corresponds to setMaximumSize(QSize(maxw, maxh)). More...
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 This function corresponds to setMinimumSize(QSize(minw, minh)). More...
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 Use the single-argument overload instead. More...
 
void setParent (QWidget *parent)
 Sets the parent of the widget to parent, and resets the window flags. More...
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 This function also takes widget flags, f as an argument. More...
 
void setShortcutAutoRepeat (int id, bool enable=true)
 If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More...
 
void setShortcutEnabled (int id, bool enable=true)
 If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More...
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 Sets the x (width) size increment to w and the y (height) size increment to h. More...
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More...
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *)
 Sets the widget's GUI style to style. More...
 
void setToolTip (const QString &)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 Sets up the user interface for the specified widget. More...
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &)
 Sets the window's role to role. More...
 
void setWindowState (Qt::WindowStates state)
 Sets the window state to windowState. More...
 
void setWindowSurface (QWindowSurface *surface)
 Sets the window surface to be the surface specified. More...
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *)
 Places the widget under w in the parent widget's stack. More...
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute) const
 Returns true if attribute attribute is set on this widget; otherwise returns false. More...
 
QString toolTip () const
 
QWidgettopLevelWidget () const
 
bool underMouse () const
 Returns true if the widget is under the mouse cursor; otherwise returns false. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the widget from a given gesture type. More...
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (int x, int y, int w, int h)
 This version updates a rectangle (x, y, w, h) inside the widget. More...
 
void update (const QRect &)
 This version updates a rectangle rect inside the widget. More...
 
void update (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void updateGeometry ()
 Notifies the layout system that this widget has changed and may need to change geometry. More...
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 Returns the unobscured region where paint events can occur. More...
 
QString whatsThis () const
 
int width () const
 
QWidgetwindow () const
 Returns the window for this widget, i.e. More...
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 Window flags are a combination of a type (e. More...
 
QIcon windowIcon () const
 
QString windowIconText () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 Returns the window's role, or an empty string. More...
 
Qt::WindowStates windowState () const
 Returns the current window state. More...
 
QWindowSurfacewindowSurface () const
 Returns the QWindowSurface this widget will be drawn into. More...
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 Returns the window type of this widget. More...
 
WId winId () const
 Returns the window system identifier of the widget. More...
 
int x () const
 
const QX11Infox11Info () const
 Returns information about the configuration of the X display used to display the widget. More...
 
Qt::HANDLE x11PictureHandle () const
 Returns the X11 Picture handle of the widget for XRender support. More...
 
int y () const
 
 ~QWidget ()
 Destroys the widget. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Protected Functions

void changeEvent (QEvent *)
 Reimplemented Function More...
 
bool event (QEvent *)
 Reimplemented Function More...
 
void initStyleOption (QStyleOptionTabWidgetFrame *option) const
 Initialize option with the values from this QTabWidget. More...
 
void keyPressEvent (QKeyEvent *)
 Reimplemented Function More...
 
void paintEvent (QPaintEvent *)
 Paints the tab widget's tab bar in response to the paint event. More...
 
void resizeEvent (QResizeEvent *)
 Reimplemented Function More...
 
void setTabBar (QTabBar *)
 Replaces the dialog's QTabBar heading with the tab bar tb. More...
 
void showEvent (QShowEvent *)
 Reimplemented Function More...
 
QTabBartabBar () const
 Returns the current QTabBar. More...
 
virtual void tabInserted (int index)
 This virtual handler is called after a new tab was added or inserted at position index. More...
 
virtual void tabRemoved (int index)
 This virtual handler is called after a tab was removed from position index. More...
 
- Protected Functions inherited from QWidget
virtual void actionEvent (QActionEvent *)
 This event handler is called with the given event whenever the widget's actions are changed. More...
 
virtual void closeEvent (QCloseEvent *)
 This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system. More...
 
virtual void contextMenuEvent (QContextMenuEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive widget context menu events. More...
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 Creates a new widget window if window is 0, otherwise sets the widget's window to window. More...
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 Frees up window system resources. More...
 
virtual void dragEnterEvent (QDragEnterEvent *)
 This event handler is called when a drag is in progress and the mouse enters this widget. More...
 
virtual void dragLeaveEvent (QDragLeaveEvent *)
 This event handler is called when a drag is in progress and the mouse leaves this widget. More...
 
virtual void dragMoveEvent (QDragMoveEvent *)
 This event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus. More...
 
virtual void dropEvent (QDropEvent *)
 This event handler is called when the drag is dropped on this widget. More...
 
virtual void enabledChange (bool)
 
virtual void enterEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. More...
 
virtual void focusInEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. More...
 
bool focusNextChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual bool focusNextPrevChild (bool next)
 Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void focusOutEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. More...
 
bool focusPreviousChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void fontChange (const QFont &)
 
virtual void hideEvent (QHideEvent *)
 This event handler can be reimplemented in a subclass to receive widget hide events. More...
 
virtual void inputMethodEvent (QInputMethodEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events. More...
 
virtual void keyReleaseEvent (QKeyEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget. More...
 
virtual void languageChange ()
 
virtual void leaveEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter. More...
 
virtual bool macEvent (EventHandlerCallRef, EventRef)
 This special event handler can be reimplemented in a subclass to receive native Macintosh events. More...
 
int metric (PaintDeviceMetric) const
 Internal implementation of the virtual QPaintDevice::metric() function. More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget. More...
 
virtual void mouseMoveEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse move events for the widget. More...
 
virtual void mousePressEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget. More...
 
virtual void mouseReleaseEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse release events for the widget. More...
 
virtual void moveEvent (QMoveEvent *)
 This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More...
 
virtual void paletteChange (const QPalette &)
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
virtual bool qwsEvent (QWSEvent *)
 This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More...
 
void resetInputContext ()
 This function can be called on the widget that currently has focus to reset the input method operating on it. More...
 
virtual void styleChange (QStyle &)
 
virtual void tabletEvent (QTabletEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More...
 
virtual void wheelEvent (QWheelEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive wheel events for the widget. More...
 
virtual void windowActivationChange (bool)
 
virtual bool winEvent (MSG *message, long *result)
 This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More...
 
virtual bool x11Event (XEvent *)
 This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Private Functions

void setUpLayout (bool=false)
 

Properties

int count
 the number of tabs in the tab bar More...
 
int currentIndex
 the index position of the current tab page More...
 
bool documentMode
 Whether or not the tab widget is rendered in a mode suitable for document pages. More...
 
Qt::TextElideMode elideMode
 how to elide text in the tab bar More...
 
QSize iconSize
 The size for icons in the tab bar. More...
 
bool movable
 This property holds whether the user can move the tabs within the tabbar area. More...
 
TabPosition tabPosition
 the position of the tabs in this tab widget More...
 
bool tabsClosable
 whether close buttons are automatically added to each tab. More...
 
TabShape tabShape
 the shape of the tabs in this tab widget More...
 
bool usesScrollButtons
 Whether or not a tab bar should use buttons to scroll tabs when it has many tabs. More...
 

Friends

class Q3TabDialog
 

Additional Inherited Members

- Static Public Functions inherited from QWidget
static QWidgetfind (WId)
 Returns a pointer to the widget with window identifer/handle id. More...
 
static QWidgetkeyboardGrabber ()
 Returns the widget that is currently grabbing the keyboard input. More...
 
static QWidgetmouseGrabber ()
 Returns the widget that is currently grabbing the mouse input. More...
 
static void setTabOrder (QWidget *, QWidget *)
 Puts the second widget after the first widget in the focus order. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 Updates the widget's micro focus. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QPaintDevice
ushort painters
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QTabWidget class provides a stack of tabbed widgets.

A tab widget provides a tab bar (see QTabBar) and a "page area" that is used to display pages related to each tab. By default, the tab bar is shown above the page area, but different configurations are available (see TabPosition). Each tab is associated with a different widget (called a page). Only the current page is shown in the page area; all the other pages are hidden. The user can show a different page by clicking on its tab or by pressing its Alt+letter shortcut if it has one.

The normal way to use QTabWidget is to do the following:

  1. Create a QTabWidget.
  2. Create a QWidget for each of the pages in the tab dialog, but do not specify parent widgets for them.
  3. Insert child widgets into the page widget, using layouts to position them as normal.
  4. Call addTab() or insertTab() to put the page widgets into the tab widget, giving each tab a suitable label with an optional keyboard shortcut.

The position of the tabs is defined by tabPosition , their shape by tabShape .

The signal currentChanged() is emitted when the user selects a page.

The current page index is available as currentIndex(), the current page widget with currentWidget(). You can retrieve a pointer to a page widget with a given index using widget(), and can find the index position of a widget with indexOf(). Use setCurrentWidget() or setCurrentIndex() to show a particular page.

You can change a tab's text and icon using setTabText() or setTabIcon(). A tab and its associated page can be removed with removeTab().

Each tab is either enabled or disabled at any given time (see setTabEnabled()). If a tab is enabled, the tab text is drawn normally and the user can select that tab. If it is disabled, the tab is drawn in a different way and the user cannot select that tab. Note that even if a tab is disabled, the page can still be visible, for example if all of the tabs happen to be disabled.

Tab widgets can be a very good way to split up a complex dialog. An alternative is to use a QStackedWidget for which you provide some means of navigating between pages, for example, a QToolBar or a QListWidget.

Most of the functionality in QTabWidget is provided by a QTabBar (at the top, providing the tabs) and a QStackedWidget (most of the area, organizing the individual pages).

windowsxp-tabwidget.png
Screenshot of a Windows XP style tab widget
macintosh-tabwidget.png
Screenshot of a Macintosh style tab widget
plastique-tabwidget.png
Screenshot of a Plastique style tab widget
A Windows XP style tab widget. A Macintosh style tab widget. A Plastique style tab widget.
See also
QTabBar, QStackedWidget, QToolBox, {Tab Dialog Example}

Definition at line 60 of file qtabwidget.h.

Enumerations

◆ TabPosition

This enum type defines where QTabWidget draws the tab row:

  • North The tabs are drawn above the pages.
  • South The tabs are drawn below the pages.
  • West The tabs are drawn to the left of the pages.
  • East The tabs are drawn to the right of the pages.
  • Bottom
  • Top
Enumerator
North 
South 
West 
East 

Definition at line 112 of file qtabwidget.h.

112  { North, South, West, East
113 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
114  , Top = North, Bottom = South
115 #endif
116  };

◆ TabShape

This enum type defines the shape of the tabs:

  • Rounded The tabs are drawn with a rounded look.

This is the default shape.

  • Triangular The tabs are drawn with a triangular look.
Enumerator
Rounded 
Triangular 

Definition at line 126 of file qtabwidget.h.

Constructors and Destructors

◆ QTabWidget()

QTabWidget::QTabWidget ( QWidget parent = 0)
explicit

Constructs a tabbed widget with parent parent.

Definition at line 359 of file qtabwidget.cpp.

360  : QWidget(*new QTabWidgetPrivate, parent, 0)
361 {
362  Q_D(QTabWidget);
363  d->init();
364 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a widget which is a child of parent, with widget flags set to f.
Definition: qwidget.cpp:1189
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ ~QTabWidget()

QTabWidget::~QTabWidget ( )

Destroys the tabbed widget.

Definition at line 383 of file qtabwidget.cpp.

384 {
385 }

Functions

◆ addTab() [1/2]

int QTabWidget::addTab ( QWidget page,
const QString label 
)

Adds a tab with the given page and label to the tab widget, and returns the index of the tab in the tab bar.

If the tab's label contains an ampersand, the letter following the ampersand is used as a shortcut for the tab, e.g. if the label is "Bro\&wse" then Alt+W becomes a shortcut which will move the focus to this tab.

Note
If you call addTab() after show(), the layout system will try to adjust to the changes in its widgets hierarchy and may cause flicker. To prevent this, you can set the QWidget::updatesEnabled property to false prior to changes; remember to set the property to true when the changes are done, making the widget receive paint events again.
See also
insertTab()

Definition at line 407 of file qtabwidget.cpp.

408 {
409  return insertTab(-1, child, label);
410 }
int insertTab(int index, QWidget *widget, const QString &)
Inserts a tab with the given label and page into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar.
Definition: qtabwidget.cpp:461

◆ addTab() [2/2]

int QTabWidget::addTab ( QWidget page,
const QIcon icon,
const QString label 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds a tab with the given page, icon, and label to the tab widget, and returns the index of the tab in the tab bar.

This function is the same as addTab(), but with an additional icon.

Definition at line 423 of file qtabwidget.cpp.

424 {
425  return insertTab(-1, child, icon, label);
426 }
int insertTab(int index, QWidget *widget, const QString &)
Inserts a tab with the given label and page into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar.
Definition: qtabwidget.cpp:461

◆ changeEvent()

void QTabWidget::changeEvent ( QEvent ev)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1114 of file qtabwidget.cpp.

1115 {
1116  if (ev->type() == QEvent::StyleChange
1117 #ifdef Q_WS_MAC
1118  || ev->type() == QEvent::MacSizeChange
1119 #endif
1120  )
1121  setUpLayout();
1123 }
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ clear()

void QTabWidget::clear ( )

Removes all the pages, but does not delete them.

Calling this function is equivalent to calling removeTab() until the tab widget is empty.

Definition at line 1419 of file qtabwidget.cpp.

1420 {
1421  // ### optimize by introduce QStackedLayout::clear()
1422  while (count())
1423  removeTab(0);
1424 }
void removeTab(int index)
Removes the tab at position index from this stack of widgets.
Definition: qtabwidget.cpp:637
int count() const

◆ cornerWidget()

QWidget * QTabWidget::cornerWidget ( Qt::Corner  corner = Qt::TopRightCorner) const

Returns the widget shown in the corner of the tab widget or 0.

Definition at line 623 of file qtabwidget.cpp.

Referenced by paintEvent().

624 {
625  Q_D(const QTabWidget);
626  if (corner & Qt::TopRightCorner)
627  return d->rightCornerWidget;
628  return d->leftCornerWidget;
629 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ count()

int QTabWidget::count ( ) const

◆ currentChanged

void QTabWidget::currentChanged ( int  index)
signal

This signal is emitted whenever the current page index changes.

Use currentChanged(int) instead.

The parameter is the new current page index position, or -1 if there isn't a new one (for example, if there are no widgets in the QTabWidget)

See also
currentWidget() currentIndex

Referenced by setTabBar().

◆ currentIndex()

int QTabWidget::currentIndex ( ) const

Referenced by keyPressEvent(), and setCurrentWidget().

◆ currentWidget()

QWidget * QTabWidget::currentWidget ( ) const

Returns a pointer to the page currently being displayed by the tab dialog.

The tab dialog does its best to make sure that this value is never 0 (but if you try hard enough, it can be).

See also
currentIndex(), setCurrentWidget()

Definition at line 652 of file qtabwidget.cpp.

653 {
654  Q_D(const QTabWidget);
655  return d->stack->currentWidget();
656 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ documentMode()

bool QTabWidget::documentMode ( ) const

◆ elideMode()

Qt::TextElideMode QTabWidget::elideMode ( ) const

Referenced by setIconSize().

◆ event()

bool QTabWidget::event ( QEvent ev)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1104 of file qtabwidget.cpp.

1105 {
1106  if (ev->type() == QEvent::LayoutRequest)
1107  setUpLayout();
1108  return QWidget::event(ev);
1109 }
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ heightForWidth()

int QTabWidget::heightForWidth ( int  width) const
virtual

Reimplemented Function

Since
4.8

Reimplemented from QWidget.

Definition at line 917 of file qtabwidget.cpp.

918 {
919  Q_D(const QTabWidget);
921  initStyleOption(&opt);
923 
924  QSize zero(0,0);
925  const QSize padding = style()->sizeFromContents(QStyle::CT_TabWidget, &opt, zero, this)
927 
928  QSize lc(0, 0), rc(0, 0);
929  if (d->leftCornerWidget)
930  lc = d->leftCornerWidget->sizeHint();
931  if(d->rightCornerWidget)
932  rc = d->rightCornerWidget->sizeHint();
933  if (!d->dirty) {
934  QTabWidget *that = (QTabWidget*)this;
935  that->setUpLayout(true);
936  }
937  QSize t(d->tabs->sizeHint());
938 
939  if(usesScrollButtons())
940  t = t.boundedTo(QSize(200,200));
941  else
943 
944  const bool tabIsHorizontal = (d->pos == North || d->pos == South);
945  const int contentsWidth = width - padding.width();
946  int stackWidth = contentsWidth;
947  if (!tabIsHorizontal)
948  stackWidth -= qMax(t.width(), qMax(lc.width(), rc.width()));
949 
950  int stackHeight = d->stack->heightForWidth(stackWidth);
951  QSize s(stackWidth, stackHeight);
952 
953  QSize contentSize = basicSize(tabIsHorizontal, lc, rc, s, t);
954  return (contentSize + padding).expandedTo(QApplication::globalStrut()).height();
955 }
double d
Definition: qnumeric_p.h:62
QSize size() const
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
bool usesScrollButtons() const
static QSize globalStrut()
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
#define Q_D(Class)
Definition: qglobal.h:2482
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QStyle * style() const
Definition: qwidget.cpp:2742
int width() const
Returns the width.
Definition: qsize.h:126
int width() const
void initStyleOption(QStyleOptionTabWidgetFrame *option) const
Initialize option with the values from this QTabWidget.
Definition: qtabwidget.cpp:284
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
static const int zero
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
The QStyleOptionTabWidgetFrameV2 class is used to describe the parameters for drawing the frame aroun...
Definition: qstyleoption.h:196
static QSize basicSize(bool horizontal, const QSize &lc, const QSize &rc, const QSize &s, const QSize &t)
Definition: qtabwidget.cpp:836

◆ iconSize()

QSize QTabWidget::iconSize ( ) const

Referenced by paintEvent().

◆ indexOf()

int QTabWidget::indexOf ( QWidget widget) const

Returns the index position of the page occupied by the widget w, or -1 if the widget cannot be found.

Definition at line 701 of file qtabwidget.cpp.

Referenced by setCurrentWidget().

702 {
703  Q_D(const QTabWidget);
704  return d->stack->indexOf(w);
705 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ initStyleOption()

void QTabWidget::initStyleOption ( QStyleOptionTabWidgetFrame option) const
protected

Initialize option with the values from this QTabWidget.

This method is useful for subclasses when they need a QStyleOptionTabWidgetFrame, but don't want to fill in all the information themselves.

See also
QStyleOption::initFrom() QTabBar::initStyleOption()

Definition at line 284 of file qtabwidget.cpp.

Referenced by heightForWidth(), minimumSizeHint(), paintEvent(), setUpLayout(), and sizeHint().

285 {
286  if (!option)
287  return;
288 
289  Q_D(const QTabWidget);
290  option->initFrom(this);
291 
292  if (documentMode())
293  option->lineWidth = 0;
294  else
296 
297  int exth = style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0, this);
298  QSize t(0, d->stack->frameWidth());
299  if (d->tabs->isVisibleTo(const_cast<QTabWidget *>(this))) {
300  t = d->tabs->sizeHint();
301  if (documentMode()) {
302  if (tabPosition() == East || tabPosition() == West) {
303  t.setHeight(height());
304  } else {
305  t.setWidth(width());
306  }
307  }
308  }
309 
310  if (d->rightCornerWidget) {
311  const QSize rightCornerSizeHint = d->rightCornerWidget->sizeHint();
312  const QSize bounds(rightCornerSizeHint.width(), t.height() - exth);
313  option->rightCornerWidgetSize = rightCornerSizeHint.boundedTo(bounds);
314  } else {
315  option->rightCornerWidgetSize = QSize(0, 0);
316  }
317 
318  if (d->leftCornerWidget) {
319  const QSize leftCornerSizeHint = d->leftCornerWidget->sizeHint();
320  const QSize bounds(leftCornerSizeHint.width(), t.height() - exth);
321  option->leftCornerWidgetSize = leftCornerSizeHint.boundedTo(bounds);
322  } else {
323  option->leftCornerWidgetSize = QSize(0, 0);
324  }
325 
326  switch (d->pos) {
327  case QTabWidget::North:
328  option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedNorth
330  break;
331  case QTabWidget::South:
332  option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedSouth
334  break;
335  case QTabWidget::West:
336  option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedWest
338  break;
339  case QTabWidget::East:
340  option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedEast
342  break;
343  }
344 
345  option->tabBarSize = t;
346 
347  if (QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(option)) {
348  QRect tbRect = tabBar()->geometry();
349  QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex());
350  tabframe->tabBarRect = tbRect;
351  selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft());
352  tabframe->selectedTabRect = selectedTabRect;
353  }
354 }
int currentIndex() const
double d
Definition: qnumeric_p.h:62
QSize leftCornerWidgetSize
the size of the left-corner widget
Definition: qstyleoption.h:186
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QSize tabBarSize
the size of the tab bar
Definition: qstyleoption.h:184
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
QStyle * style() const
Definition: qwidget.cpp:2742
int width() const
Returns the width.
Definition: qsize.h:126
QTabBar * tabBar() const
Returns the current QTabBar.
Definition: qtabwidget.cpp:753
int width() const
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
int lineWidth
the line width for drawing the panel
Definition: qstyleoption.h:181
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:368
TabPosition tabPosition() const
QSize rightCornerWidgetSize
the size of the right-corner widget
Definition: qstyleoption.h:185
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRect tabRect(int index) const
Returns the visual rectangle of the tab at position index, or a null rectangle if index is out of ran...
Definition: qtabbar.cpp:1179
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
const QRect & geometry() const
bool documentMode() const
The QStyleOptionTabWidgetFrameV2 class is used to describe the parameters for drawing the frame aroun...
Definition: qstyleoption.h:196
QTabBar::Shape shape
the tab shape used to draw the tabs
Definition: qstyleoption.h:183
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ insertTab() [1/2]

int QTabWidget::insertTab ( int  index,
QWidget page,
const QString label 
)

Inserts a tab with the given label and page into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar.

The label is displayed in the tab and may vary in appearance depending on the configuration of the tab widget.

If the tab's label contains an ampersand, the letter following the ampersand is used as a shortcut for the tab, e.g. if the label is "Bro\&wse" then Alt+W becomes a shortcut which will move the focus to this tab.

If index is out of range, the tab is simply appended. Otherwise it is inserted at the specified position.

If the QTabWidget was empty before this function is called, the new page becomes the current page. Inserting a new tab at an index less than or equal to the current index will increment the current index, but keep the current page.

Note
If you call insertTab() after show(), the layout system will try to adjust to the changes in its widgets hierarchy and may cause flicker. To prevent this, you can set the QWidget::updatesEnabled property to false prior to changes; remember to set the property to true when the changes are done, making the widget receive paint events again.
See also
addTab()

Definition at line 461 of file qtabwidget.cpp.

Referenced by addTab().

462 {
463  return insertTab(index, w, QIcon(), label);
464 }
quint16 index
int insertTab(int index, QWidget *widget, const QString &)
Inserts a tab with the given label and page into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar.
Definition: qtabwidget.cpp:461
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ insertTab() [2/2]

int QTabWidget::insertTab ( int  index,
QWidget page,
const QIcon icon,
const QString label 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts a tab with the given label, page, and icon into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar.

This function is the same as insertTab(), but with an additional icon.

Definition at line 478 of file qtabwidget.cpp.

479 {
480  Q_D(QTabWidget);
481  if(!w)
482  return -1;
483  index = d->stack->insertWidget(index, w);
484  d->tabs->insertTab(index, icon, label);
485  setUpLayout();
487 
488  return index;
489 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
virtual void tabInserted(int index)
This virtual handler is called after a new tab was added or inserted at position index.

◆ isMovable()

bool QTabWidget::isMovable ( ) const

Definition at line 1063 of file qtabwidget.cpp.

1064 {
1065  return tabBar()->isMovable();
1066 }
QTabBar * tabBar() const
Returns the current QTabBar.
Definition: qtabwidget.cpp:753
bool isMovable() const
Definition: qtabbar.cpp:2293

◆ isTabEnabled()

bool QTabWidget::isTabEnabled ( int  index) const

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

Use isTabEnabled(tabWidget->indexOf(widget)) instead.

See also
setTabEnabled(), QWidget::isEnabled()

Definition at line 552 of file qtabwidget.cpp.

553 {
554  Q_D(const QTabWidget);
555  return d->tabs->isTabEnabled(index);
556 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ keyPressEvent()

void QTabWidget::keyPressEvent ( QKeyEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1129 of file qtabwidget.cpp.

1130 {
1131  Q_D(QTabWidget);
1132  if (((e->key() == Qt::Key_Tab || e->key() == Qt::Key_Backtab) &&
1133  count() > 1 && e->modifiers() & Qt::ControlModifier)
1134 #ifdef QT_KEYPAD_NAVIGATION
1135  || QApplication::keypadNavigationEnabled() && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right) && count() > 1
1136 #endif
1137  ) {
1138  int pageCount = d->tabs->count();
1139  int page = currentIndex();
1140  int dx = (e->key() == Qt::Key_Backtab || e->modifiers() & Qt::ShiftModifier) ? -1 : 1;
1141 #ifdef QT_KEYPAD_NAVIGATION
1142  if (QApplication::keypadNavigationEnabled() && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right))
1143  dx = e->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1;
1144 #endif
1145  for (int pass = 0; pass < pageCount; ++pass) {
1146  page+=dx;
1147  if (page < 0
1148 #ifdef QT_KEYPAD_NAVIGATION
1149  && !e->isAutoRepeat()
1150 #endif
1151  ) {
1152  page = count() - 1;
1153  } else if (page >= pageCount
1154 #ifdef QT_KEYPAD_NAVIGATION
1155  && !e->isAutoRepeat()
1156 #endif
1157  ) {
1158  page = 0;
1159  }
1160  if (d->tabs->isTabEnabled(page)) {
1161  setCurrentIndex(page);
1162  break;
1163  }
1164  }
1166  d->tabs->setFocus();
1167  } else {
1168  e->ignore();
1169  }
1170 }
int currentIndex() const
double d
Definition: qnumeric_p.h:62
int count() const
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
bool isAutoRepeat() const
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initia...
Definition: qevent.h:237
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void setCurrentIndex(int index)
Definition: qtabwidget.cpp:690
bool isRightToLeft() const
Definition: qwidget.h:428
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...

◆ minimumSizeHint()

QSize QTabWidget::minimumSizeHint ( ) const
virtual

Returns a suitable minimum size for the tab widget.

Reimplemented Function

Reimplemented from QWidget.

Definition at line 887 of file qtabwidget.cpp.

888 {
889  Q_D(const QTabWidget);
890  QSize lc(0, 0), rc(0, 0);
891 
892  if(d->leftCornerWidget)
893  lc = d->leftCornerWidget->minimumSizeHint();
894  if(d->rightCornerWidget)
895  rc = d->rightCornerWidget->minimumSizeHint();
896  if (!d->dirty) {
897  QTabWidget *that = (QTabWidget*)this;
898  that->setUpLayout(true);
899  }
900  QSize s(d->stack->minimumSizeHint());
901  QSize t(d->tabs->minimumSizeHint());
902 
903  QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);
904 
906  initStyleOption(&opt);
907  opt.palette = palette();
909  return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this)
911 }
double d
Definition: qnumeric_p.h:62
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
static QSize globalStrut()
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
const QPalette & palette() const
void initStyleOption(QStyleOptionTabWidgetFrame *option) const
Initialize option with the values from this QTabWidget.
Definition: qtabwidget.cpp:284
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
The QStyleOptionTabWidgetFrameV2 class is used to describe the parameters for drawing the frame aroun...
Definition: qstyleoption.h:196
static QSize basicSize(bool horizontal, const QSize &lc, const QSize &rc, const QSize &s, const QSize &t)
Definition: qtabwidget.cpp:836

◆ paintEvent()

void QTabWidget::paintEvent ( QPaintEvent event)
protectedvirtual

Paints the tab widget's tab bar in response to the paint event.

Reimplemented from QWidget.

Definition at line 1281 of file qtabwidget.cpp.

1282 {
1283  Q_D(QTabWidget);
1284  if (documentMode()) {
1285  QStylePainter p(this, tabBar());
1289  opt.rect.moveLeft(w->x() + opt.rect.x());
1290  opt.rect.moveTop(w->y() + opt.rect.y());
1291  p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt);
1292  }
1296  opt.rect.moveLeft(w->x() + opt.rect.x());
1297  opt.rect.moveTop(w->y() + opt.rect.y());
1298  p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt);
1299  }
1300  return;
1301  }
1302  QStylePainter p(this);
1303 
1305  initStyleOption(&opt);
1306  opt.rect = d->panelRect;
1307  p.drawPrimitive(QStyle::PE_FrameTabWidget, opt);
1308 }
double d
Definition: qnumeric_p.h:62
QSize size() const
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * cornerWidget(Qt::Corner corner=Qt::TopRightCorner) const
Returns the widget shown in the corner of the tab widget or 0.
Definition: qtabwidget.cpp:623
QTabBar * tabBar() const
Returns the current QTabBar.
Definition: qtabwidget.cpp:753
void initStyleOption(QStyleOptionTabWidgetFrame *option) const
Initialize option with the values from this QTabWidget.
Definition: qtabwidget.cpp:284
The QStyleOptionTabBarBaseV2 class is used to describe the base of a tab bar, i.e.
Definition: qstyleoption.h:235
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
Definition: qtabbar_p.h:208
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget...
Definition: qstylepainter.h:55
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
bool documentMode() const
The QStyleOptionTabWidgetFrameV2 class is used to describe the parameters for drawing the frame aroun...
Definition: qstyleoption.h:196
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ removeTab()

void QTabWidget::removeTab ( int  index)

Removes the tab at position index from this stack of widgets.

The page widget itself is not deleted.

See also
addTab(), insertTab()

Definition at line 637 of file qtabwidget.cpp.

Referenced by clear().

638 {
639  Q_D(QTabWidget);
640  if (QWidget *w = d->stack->widget(index))
641  d->stack->removeWidget(w);
642 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ resizeEvent()

void QTabWidget::resizeEvent ( QResizeEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 711 of file qtabwidget.cpp.

712 {
714  setUpLayout();
715 }
virtual void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition: qwidget.cpp:9587
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798

◆ setCornerWidget()

void QTabWidget::setCornerWidget ( QWidget widget,
Qt::Corner  corner = Qt::TopRightCorner 
)

Sets the given widget to be shown in the specified corner of the tab widget.

The geometry of the widget is determined based on the widget's sizeHint() and the style().

Only the horizontal element of the corner will be used.

Passing 0 shows no widget in the corner.

Any previously set corner widget is hidden.

All widgets set here will be deleted by the tab widget when it is destroyed unless you separately reparent the widget after setting some other corner widget (or 0).

Note: Corner widgets are designed for North and South tab positions; other orientations are known to not work properly.

See also
cornerWidget(), setTabPosition()

Definition at line 602 of file qtabwidget.cpp.

603 {
604  Q_D(QTabWidget);
605  if (widget && widget->parentWidget() != this)
606  widget->setParent(this);
607 
608  if (corner & Qt::TopRightCorner) {
609  if (d->rightCornerWidget)
610  d->rightCornerWidget->hide();
611  d->rightCornerWidget = widget;
612  } else {
613  if (d->leftCornerWidget)
614  d->leftCornerWidget->hide();
615  d->leftCornerWidget = widget;
616  }
617  setUpLayout();
618 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * widget(int index) const
Returns the tab page at index position index or 0 if the index is out of range.
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setCurrentIndex

void QTabWidget::setCurrentIndex ( int  index)
slot

Definition at line 690 of file qtabwidget.cpp.

Referenced by keyPressEvent().

691 {
692  Q_D(QTabWidget);
693  d->tabs->setCurrentIndex(index);
694 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setCurrentWidget

void QTabWidget::setCurrentWidget ( QWidget widget)
slot

Makes widget the current widget.

The widget used must be a page in this tab widget.

See also
addTab(), setCurrentIndex(), currentWidget()

Definition at line 664 of file qtabwidget.cpp.

665 {
666  Q_D(const QTabWidget);
667  d->tabs->setCurrentIndex(indexOf(widget));
668 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
int indexOf(QWidget *widget) const
Returns the index position of the page occupied by the widget w, or -1 if the widget cannot be found...
Definition: qtabwidget.cpp:701

◆ setDocumentMode()

void QTabWidget::setDocumentMode ( bool  set)

Definition at line 1406 of file qtabwidget.cpp.

1407 {
1408  Q_D(QTabWidget);
1409  d->tabs->setDocumentMode(enabled);
1410  d->tabs->setExpanding(!enabled);
1411  d->tabs->setDrawBase(enabled);
1412  setUpLayout();
1413 }
double d
Definition: qnumeric_p.h:62
bool enabled
whether the widget is enabled
Definition: qwidget.h:157
#define Q_D(Class)
Definition: qglobal.h:2482
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setElideMode()

void QTabWidget::setElideMode ( Qt::TextElideMode  mode)

Definition at line 1354 of file qtabwidget.cpp.

1355 {
1356  d_func()->tabs->setElideMode(mode);
1357 }

◆ setIconSize()

void QTabWidget::setIconSize ( const QSize size)

Definition at line 1329 of file qtabwidget.cpp.

1330 {
1331  d_func()->tabs->setIconSize(size);
1332 }

◆ setMovable()

void QTabWidget::setMovable ( bool  movable)

Definition at line 1068 of file qtabwidget.cpp.

1069 {
1071 }
bool movable
This property holds whether the user can move the tabs within the tabbar area.
Definition: qtabwidget.h:73
QTabBar * tabBar() const
Returns the current QTabBar.
Definition: qtabwidget.cpp:753
void setMovable(bool movable)
Definition: qtabbar.cpp:2299

◆ setTabBar()

void QTabWidget::setTabBar ( QTabBar tb)
protected

Replaces the dialog's QTabBar heading with the tab bar tb.

Note that this must be called before any tabs have been added, or the behavior is undefined.

See also
tabBar()

Definition at line 724 of file qtabwidget.cpp.

725 {
726  Q_D(QTabWidget);
727  Q_ASSERT(tb);
728 
729  if (tb->parentWidget() != this) {
730  tb->setParent(this);
731  tb->show();
732  }
733  delete d->tabs;
734  d->tabs = tb;
735  setFocusProxy(d->tabs);
736  connect(d->tabs, SIGNAL(currentChanged(int)),
737  this, SLOT(_q_showTab(int)));
738  connect(d->tabs, SIGNAL(tabMoved(int,int)),
739  this, SLOT(_q_tabMoved(int,int)));
740  if (d->tabs->tabsClosable())
741  connect(d->tabs, SIGNAL(tabCloseRequested(int)),
742  this, SIGNAL(tabCloseRequested(int)));
743  tb->setExpanding(!documentMode());
744  setUpLayout();
745 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
#define SLOT(a)
Definition: qobjectdefs.h:226
void currentChanged(int index)
This signal is emitted whenever the current page index changes.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void setExpanding(bool enabled)
Definition: qtabbar.cpp:2271
void show()
Shows the widget and its child widgets.
void setFocusProxy(QWidget *)
Sets the widget&#39;s focus proxy to widget w.
Definition: qwidget.cpp:6537
void tabCloseRequested(int index)
This signal is emitted when the close button on a tab is clicked.
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
bool documentMode() const

◆ setTabEnabled()

void QTabWidget::setTabEnabled ( int  index,
bool  enable 
)

If enable is true, the page at position index is enabled; otherwise the page at position index is disabled.

Use setTabEnabled(tabWidget->indexOf(widget), b) instead.

The page's tab is redrawn appropriately.

QTabWidget uses QWidget::setEnabled() internally, rather than keeping a separate flag.

Note that even a disabled tab/page may be visible. If the page is visible already, QTabWidget will not hide it; if all the pages are disabled, QTabWidget will show one of them.

See also
isTabEnabled(), QWidget::setEnabled()

Definition at line 572 of file qtabwidget.cpp.

573 {
574  Q_D(QTabWidget);
575  d->tabs->setTabEnabled(index, enable);
576  if (QWidget *widget = d->stack->widget(index))
577  widget->setEnabled(enable);
578 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setEnabled(bool)
Definition: qwidget.cpp:3447
quint16 index
QWidget * widget(int index) const
Returns the tab page at index position index or 0 if the index is out of range.
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setTabIcon()

void QTabWidget::setTabIcon ( int  index,
const QIcon icon 
)

Sets the icon for the tab at position index.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 529 of file qtabwidget.cpp.

530 {
531  Q_D(QTabWidget);
532  d->tabs->setTabIcon(index, icon);
533  setUpLayout();
534 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setTabPosition()

void QTabWidget::setTabPosition ( TabPosition  pos)

Definition at line 1010 of file qtabwidget.cpp.

1011 {
1012  Q_D(QTabWidget);
1013  if (d->pos == pos)
1014  return;
1015  d->pos = pos;
1016  d->updateTabBarPosition();
1017 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setTabsClosable()

void QTabWidget::setTabsClosable ( bool  closeable)

Definition at line 1035 of file qtabwidget.cpp.

1036 {
1037  if (tabsClosable() == closeable)
1038  return;
1039 
1040  tabBar()->setTabsClosable(closeable);
1041  if (closeable)
1043  this, SIGNAL(tabCloseRequested(int)));
1044  else
1046  this, SIGNAL(tabCloseRequested(int)));
1047  setUpLayout();
1048 }
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QTabBar * tabBar() const
Returns the current QTabBar.
Definition: qtabwidget.cpp:753
void setTabsClosable(bool closable)
Definition: qtabbar.cpp:2158
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
bool tabsClosable() const
void tabCloseRequested(int index)
This signal is emitted when the close button on a tab is clicked.
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798

◆ setTabShape()

void QTabWidget::setTabShape ( TabShape  s)

Definition at line 1092 of file qtabwidget.cpp.

1093 {
1094  Q_D(QTabWidget);
1095  if (d->shape == s)
1096  return;
1097  d->shape = s;
1098  d->updateTabBarPosition();
1099 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setTabText()

void QTabWidget::setTabText ( int  index,
const QString label 
)

Defines a new label for the page at position index's tab.

If the provided text contains an ampersand character ('&'), a shortcut is automatically created for it. The character that follows the '&' will be used as the shortcut key. Any previous shortcut will be overwritten, or cleared if no shortcut is defined by the text. See the QShortcut documentation for details (to display an actual ampersand, use '&&').

Definition at line 504 of file qtabwidget.cpp.

505 {
506  Q_D(QTabWidget);
507  d->tabs->setTabText(index, label);
508  setUpLayout();
509 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setTabToolTip()

void QTabWidget::setTabToolTip ( int  index,
const QString tip 
)

Sets the tab tool tip for the page at position index to tip.

Use setTabToolTip(tabWidget->indexOf(widget), tip) instead.

See also
tabToolTip()

Definition at line 1203 of file qtabwidget.cpp.

1204 {
1205  Q_D(QTabWidget);
1206  d->tabs->setTabToolTip(index, tip);
1207 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setTabWhatsThis()

void QTabWidget::setTabWhatsThis ( int  index,
const QString text 
)

Sets the What's This help text for the page at position index to text.

Since
4.1

Definition at line 1232 of file qtabwidget.cpp.

1233 {
1234  Q_D(QTabWidget);
1235  d->tabs->setTabWhatsThis(index, text);
1236 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ setUpLayout()

void QTabWidget::setUpLayout ( bool  onlyCheck = false)
private

Definition at line 798 of file qtabwidget.cpp.

Referenced by changeEvent(), event(), heightForWidth(), insertTab(), minimumSizeHint(), resizeEvent(), setCornerWidget(), setDocumentMode(), setTabBar(), setTabIcon(), setTabsClosable(), setTabText(), showEvent(), and sizeHint().

799 {
800  Q_D(QTabWidget);
801  if (onlyCheck && !d->dirty)
802  return; // nothing to do
803 
805  initStyleOption(&option);
806 
807  // this must be done immediately, because QWidgetItem relies on it (even if !isVisible())
808  d->setLayoutItemMargins(QStyle::SE_TabWidgetLayoutItem, &option);
809 
810  if (!isVisible()) {
811  d->dirty = true;
812  return; // we'll do it later
813  }
814 
815  QRect tabRect = style()->subElementRect(QStyle::SE_TabWidgetTabBar, &option, this);
816  d->panelRect = style()->subElementRect(QStyle::SE_TabWidgetTabPane, &option, this);
818  QRect leftCornerRect = style()->subElementRect(QStyle::SE_TabWidgetLeftCorner, &option, this);
819  QRect rightCornerRect = style()->subElementRect(QStyle::SE_TabWidgetRightCorner, &option, this);
820 
821  d->tabs->setGeometry(tabRect);
822  d->stack->setGeometry(contentsRect);
823  if (d->leftCornerWidget)
824  d->leftCornerWidget->setGeometry(leftCornerRect);
825  if (d->rightCornerWidget)
826  d->rightCornerWidget->setGeometry(rightCornerRect);
827 
828  if (!onlyCheck)
829  update();
830  updateGeometry();
831 }
double d
Definition: qnumeric_p.h:62
QRect contentsRect() const
Returns the area inside the widget&#39;s margins.
Definition: qwidget.cpp:7544
bool isVisible() const
Definition: qwidget.h:1005
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void initStyleOption(QStyleOptionTabWidgetFrame *option) const
Initialize option with the values from this QTabWidget.
Definition: qtabwidget.cpp:284
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=0) const =0
Returns the sub-area for the given element as described in the provided style option.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372
The QStyleOptionTabWidgetFrameV2 class is used to describe the parameters for drawing the frame aroun...
Definition: qstyleoption.h:196

◆ setUsesScrollButtons()

void QTabWidget::setUsesScrollButtons ( bool  useButtons)

Definition at line 1380 of file qtabwidget.cpp.

1381 {
1382  d_func()->tabs->setUsesScrollButtons(useButtons);
1383 }

◆ showEvent()

void QTabWidget::showEvent ( QShowEvent )
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 961 of file qtabwidget.cpp.

962 {
963  setUpLayout();
964 }
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798

◆ sizeHint()

QSize QTabWidget::sizeHint ( ) const
virtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 849 of file qtabwidget.cpp.

850 {
851  Q_D(const QTabWidget);
852  QSize lc(0, 0), rc(0, 0);
854  initStyleOption(&opt);
856 
857  if (d->leftCornerWidget)
858  lc = d->leftCornerWidget->sizeHint();
859  if(d->rightCornerWidget)
860  rc = d->rightCornerWidget->sizeHint();
861  if (!d->dirty) {
862  QTabWidget *that = (QTabWidget*)this;
863  that->setUpLayout(true);
864  }
865  QSize s(d->stack->sizeHint());
866  QSize t(d->tabs->sizeHint());
867  if(usesScrollButtons())
868  t = t.boundedTo(QSize(200,200));
869  else
871 
872  QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);
873 
874  return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this)
876 }
double d
Definition: qnumeric_p.h:62
QSize size() const
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
bool usesScrollButtons() const
static QSize globalStrut()
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
#define Q_D(Class)
Definition: qglobal.h:2482
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
QStyle * style() const
Definition: qwidget.cpp:2742
void initStyleOption(QStyleOptionTabWidgetFrame *option) const
Initialize option with the values from this QTabWidget.
Definition: qtabwidget.cpp:284
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setUpLayout(bool=false)
Definition: qtabwidget.cpp:798
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
The QStyleOptionTabWidgetFrameV2 class is used to describe the parameters for drawing the frame aroun...
Definition: qstyleoption.h:196
static QSize basicSize(bool horizontal, const QSize &lc, const QSize &rc, const QSize &s, const QSize &t)
Definition: qtabwidget.cpp:836

◆ tabBar()

QTabBar * QTabWidget::tabBar ( ) const
protected

Returns the current QTabBar.

See also
setTabBar()

Definition at line 753 of file qtabwidget.cpp.

Referenced by isMovable(), paintEvent(), setMovable(), setTabPosition(), and setTabsClosable().

754 {
755  Q_D(const QTabWidget);
756  return d->tabs;
757 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ tabCloseRequested

void QTabWidget::tabCloseRequested ( int  index)
signal

This signal is emitted when the close button on a tab is clicked.

Since
4.5

The index is the index that should be removed.

See also
setTabsClosable()

Referenced by setTabBar(), and setTabsClosable().

◆ tabIcon()

QIcon QTabWidget::tabIcon ( int  index) const

Returns the icon for the tab on the page at position index.

Definition at line 540 of file qtabwidget.cpp.

541 {
542  Q_D(const QTabWidget);
543  return d->tabs->tabIcon(index);
544 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ tabInserted()

void QTabWidget::tabInserted ( int  index)
protectedvirtual

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

See also
tabRemoved()

Definition at line 1260 of file qtabwidget.cpp.

Referenced by insertTab().

1261 {
1262  Q_UNUSED(index)
1263 }
quint16 index
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ tabPosition()

TabPosition QTabWidget::tabPosition ( ) const

◆ tabRemoved()

void QTabWidget::tabRemoved ( int  index)
protectedvirtual

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

See also
tabInserted()

Definition at line 1271 of file qtabwidget.cpp.

1272 {
1273  Q_UNUSED(index)
1274 }
quint16 index
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ tabsClosable()

bool QTabWidget::tabsClosable ( ) const

Referenced by setTabPosition(), and setTabsClosable().

◆ tabShape()

TabShape QTabWidget::tabShape ( ) const

Referenced by setMovable().

◆ tabText()

QString QTabWidget::tabText ( int  index) const

Returns the label text for the tab on the page at position index.

Definition at line 515 of file qtabwidget.cpp.

516 {
517  Q_D(const QTabWidget);
518  return d->tabs->tabText(index);
519 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ tabToolTip()

QString QTabWidget::tabToolTip ( int  index) const

Returns the tab tool tip for the page at position index or an empty string if no tool tip has been set.

Use tabToolTip(tabWidget->indexOf(widget)) instead.

See also
setTabToolTip()

Definition at line 1215 of file qtabwidget.cpp.

1216 {
1217  Q_D(const QTabWidget);
1218  return d->tabs->tabToolTip(index);
1219 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ tabWhatsThis()

QString QTabWidget::tabWhatsThis ( int  index) const

Returns the What's This help text for the page at position index, or an empty string if no help text has been set.

Since
4.1

Definition at line 1247 of file qtabwidget.cpp.

1248 {
1249  Q_D(const QTabWidget);
1250  return d->tabs->tabWhatsThis(index);
1251 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

◆ usesScrollButtons()

bool QTabWidget::usesScrollButtons ( ) const

◆ widget()

QWidget * QTabWidget::widget ( int  index) const

Returns the tab page at index position index or 0 if the index is out of range.

Definition at line 1176 of file qtabwidget.cpp.

Referenced by setCornerWidget(), and setTabEnabled().

1177 {
1178  Q_D(const QTabWidget);
1179  return d->stack->widget(index);
1180 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60

Friends and Related Functions

◆ Q3TabDialog

friend class Q3TabDialog
friend

Definition at line 244 of file qtabwidget.h.

Properties

◆ count

int QTabWidget::count
private

the number of tabs in the tab bar

By default, this property contains a value of 0.

Definition at line 67 of file qtabwidget.h.

◆ currentIndex

int QTabWidget::currentIndex
private

the index position of the current tab page

The current index is -1 if there is no current widget.

By default, this property contains a value of -1 because there are initially no tabs in the widget.

Definition at line 66 of file qtabwidget.h.

◆ documentMode

bool QTabWidget::documentMode
private

Whether or not the tab widget is rendered in a mode suitable for document pages.

This is the same as document mode on Mac OS X.

Since
4.5

When this property is set the tab widget frame is not rendered. This mode is useful for showing document-type pages where the page covers most of the tab widget area.

See also
elideMode, QTabBar::documentMode, QTabBar::usesScrollButtons, QStyle::SH_TabBar_PreferNoArrows

Definition at line 71 of file qtabwidget.h.

◆ elideMode

Qt::TextElideMode QTabWidget::elideMode
private

how to elide text in the tab bar

Since
4.2

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 dependant.

See also
QTabBar::elideMode usesScrollButtons QStyle::SH_TabBar_ElideMode

Definition at line 69 of file qtabwidget.h.

◆ iconSize

QSize QTabWidget::iconSize
private

The size for icons in the tab bar.

Since
4.2

The default value is style-dependent. This is the maximum size that the icons will have. Icons are not scaled up if they are of smaller size.

See also
QTabBar::iconSize

Definition at line 68 of file qtabwidget.h.

◆ movable

QTabWidget::movable
private

This property holds whether the user can move the tabs within the tabbar area.

Since
4.5

By default, this property is false;

Definition at line 73 of file qtabwidget.h.

◆ tabPosition

QTabWidget::TabPosition QTabWidget::tabPosition
private

the position of the tabs in this tab widget

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

By default, this property is set to North .

See also
TabPosition

Definition at line 64 of file qtabwidget.h.

◆ tabsClosable

bool QTabWidget::tabsClosable
private

whether close buttons are automatically added to each tab.

Since
4.5
See also
QTabBar::tabsClosable()

Definition at line 72 of file qtabwidget.h.

◆ tabShape

QTabWidget::TabShape QTabWidget::tabShape
private

the shape of the tabs in this tab widget

Possible values for this property are QTabWidget::Rounded (default) or QTabWidget::Triangular.

See also
TabShape

Definition at line 65 of file qtabwidget.h.

◆ usesScrollButtons

bool QTabWidget::usesScrollButtons
private

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

Since
4.2

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

By default the value is style dependant.

See also
elideMode QTabBar::usesScrollButtons QStyle::SH_TabBar_PreferNoArrows

Definition at line 70 of file qtabwidget.h.


The documentation for this class was generated from the following files: