42 #include "private/qlayoutengine_p.h" 55 #include "private/qtextengine_p.h" 56 #ifndef QT_NO_ACCESSIBILITY 61 #include "private/qtabbar_p.h" 66 #include <private/qt_mac_p.h> 67 #include <private/qt_cocoa_helpers_mac_p.h> 70 #ifndef QT_NO_STYLE_S60 71 #include "qs60style.h" 87 #if (defined Q_WS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) 90 ::HIContentBorderMetrics metrics;
115 privateWidget->syncUnifiedMode();
116 #endif // QT_MAC_USE_COCOA 133 int totalTabs =
d->tabList.size();
135 if (!option || (tabIndex < 0 || tabIndex >= totalTabs))
141 option->
rect = tabRect(tabIndex);
142 bool isCurrent = tabIndex ==
d->currentIndex;
144 if (tabIndex ==
d->pressedIndex)
148 if (isCurrent && hasFocus())
152 if (isActiveWindow())
154 if (!
d->dragInProgress && option->
rect ==
d->hoverRect)
163 if (
QStyleOptionTabV2 *optionV2 = qstyleoption_cast<QStyleOptionTabV2 *>(option))
166 if (
QStyleOptionTabV3 *optionV3 = qstyleoption_cast<QStyleOptionTabV3 *>(option)) {
169 optionV3->documentMode =
d->documentMode;
172 if (tabIndex > 0 && tabIndex - 1 ==
d->currentIndex)
174 else if (tabIndex + 1 < totalTabs && tabIndex + 1 ==
d->currentIndex)
179 bool paintBeginning = (tabIndex == 0) || (
d->dragInProgress && tabIndex ==
d->pressedIndex + 1);
180 bool paintEnd = (tabIndex == totalTabs - 1) || (
d->dragInProgress && tabIndex ==
d->pressedIndex - 1);
181 if (paintBeginning) {
186 }
else if (paintEnd) {
192 #ifndef QT_NO_TABWIDGET 202 option->
text = fontMetrics().elidedText(option->
text,
d->elideMode, textRect.
width(),
372 #ifdef QT_KEYPAD_NAVIGATION 373 if (QApplication::keypadNavigationEnabled()) {
400 for (
int i = 0; i <
tabList.count(); ++i)
401 if (
tabList.at(i).enabled && q->tabRect(i).contains(p))
411 QSize size = q->size();
416 int tabChainIndex = 0;
423 tabChain[tabChainIndex].init();
424 tabChain[tabChainIndex].expansive = (tabAlignment !=
Qt::AlignLeft)
426 tabChain[tabChainIndex].
empty =
true;
441 for (i = 0; i <
tabList.count(); ++i, ++tabChainIndex) {
442 QSize sz = q->tabSizeHint(i);
447 tabList[i].minRect =
QRect(minx, 0, sz.width(), sz.height());
449 tabChain[tabChainIndex].init();
450 tabChain[tabChainIndex].sizeHint =
tabList.at(i).maxRect.width();
451 tabChain[tabChainIndex].minimumSize = sz.width();
452 tabChain[tabChainIndex].empty =
false;
453 tabChain[tabChainIndex].expansive =
true;
456 tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
460 available = size.
width();
461 maxExtent = maxHeight;
466 for (i = 0; i <
tabList.count(); ++i, ++tabChainIndex) {
467 QSize sz = q->tabSizeHint(i);
472 tabList[i].minRect =
QRect(0, miny, sz.width(), sz.height());
474 tabChain[tabChainIndex].init();
475 tabChain[tabChainIndex].sizeHint =
tabList.at(i).maxRect.height();
476 tabChain[tabChainIndex].minimumSize = sz.height();
477 tabChain[tabChainIndex].empty =
false;
478 tabChain[tabChainIndex].expansive =
true;
481 tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
485 available = size.
height();
486 maxExtent = maxWidth;
489 Q_ASSERT(tabChainIndex == tabChain.count() - 1);
491 tabChain[tabChainIndex].init();
492 tabChain[tabChainIndex].expansive = (tabAlignment !=
Qt::AlignRight)
494 tabChain[tabChainIndex].empty =
true;
497 qGeomCalc(tabChain, 0, tabChain.count(), 0,
qMax(available, last), 0);
500 for (i = 0; i <
tabList.count(); ++i) {
510 #ifndef QT_NO_STYLE_S60 516 QRect(available - extra, 0, extra, size.
height()));
521 #ifndef QT_NO_STYLE_S60 529 extra/2, arrows.
height());
530 #ifndef QT_NO_STYLE_S60 536 #ifndef QT_NO_STYLE_S60 544 extra/2, arrows.
height());
545 #ifndef QT_NO_STYLE_S60 552 #ifndef QT_NO_STYLE_S60 558 arrows.
width(), extra / 2);
566 arrows.
width(), extra/2);
568 #ifndef QT_NO_STYLE_S60 582 q->tabLayoutChange();
594 const int available = (horiz ? q->width() : q->height()) -
extraWidth();
595 const int start = horiz ? tabRect.
left() : tabRect.
top();
603 const int last = horiz ?
tabList.last().rect.right() :
tabList.last().rect.bottom();
622 q->initStyleOption(&opt, index);
650 for (
int i = start; i < q->count(); ++i) {
661 for (
int i = 0; i <
tabList.count(); ++i) {
663 if (
tabList.at(i).leftWidget == object) {
668 if (
tabList.at(i).rightWidget == object) {
674 if (tabToClose != -1)
675 emit q->tabCloseRequested(tabToClose);
684 if (sender ==
leftB) {
685 for (i =
tabList.count() - 1; i >= 0; --i) {
691 }
else if (sender ==
rightB) {
692 int availableWidth = q->width() -
extraWidth();
693 for (i = 0; i <
tabList.count(); ++i) {
701 if (sender ==
leftB) {
702 for (i =
tabList.count() - 1; i >= 0; --i) {
708 }
else if (sender ==
rightB) {
710 for (i = 0; i <
tabList.count(); ++i) {
733 if (!q->isVisible()) {
781 if (
d->shape == shape)
803 if (
d->drawBase == drawBase)
863 if (!
d->validIndex(index)) {
864 index =
d->tabList.count();
869 #ifndef QT_NO_SHORTCUT 873 if (
d->tabList.count() == 1)
878 if (
d->closeButtonOnTabs) {
887 for (
int i = 0; i <
d->tabList.count(); ++i) {
888 if (
d->tabList[i].lastTab >= index)
889 ++
d->tabList[i].lastTab;
905 if (
d->validIndex(index)) {
906 #ifndef QT_NO_SHORTCUT 909 if (
d->tabList[index].leftWidget) {
910 d->tabList[
index].leftWidget->hide();
911 d->tabList[
index].leftWidget->deleteLater();
912 d->tabList[
index].leftWidget = 0;
914 if (
d->tabList[index].rightWidget) {
915 d->tabList[
index].rightWidget->hide();
916 d->tabList[
index].rightWidget->deleteLater();
917 d->tabList[
index].rightWidget = 0;
920 int newIndex =
d->tabList[
index].lastTab;
921 d->tabList.removeAt(index);
922 for (
int i = 0; i <
d->tabList.count(); ++i) {
923 if (
d->tabList[i].lastTab == index)
924 d->tabList[i].lastTab = -1;
925 if (
d->tabList[i].lastTab > index)
926 --
d->tabList[i].lastTab;
928 if (index ==
d->currentIndex) {
932 d->currentIndex = -1;
933 if (
d->tabList.size() > 0) {
934 switch(
d->selectionBehaviorOnRemove) {
936 if (newIndex > index)
938 if (
d->validIndex(newIndex))
943 if (newIndex >=
d->tabList.size())
944 newIndex =
d->tabList.size() - 1;
947 newIndex = index - 1;
955 if (
d->validIndex(newIndex)) {
957 int bump =
d->tabList[newIndex].lastTab;
959 d->tabList[newIndex].lastTab = bump;
994 #ifndef QT_NO_SHORTCUT 998 if (!enabled && index ==
d->currentIndex)
1000 else if (enabled && !
d->validIndex(
d->currentIndex))
1026 #ifndef QT_NO_SHORTCUT 1045 return tab->textColor;
1060 tab->textColor = color;
1084 bool simpleIconChange = (!icon.
isNull() && !tab->icon.isNull());
1086 if (simpleIconChange)
1093 #ifndef QT_NO_TOOLTIP 1112 return tab->toolTip;
1115 #endif // QT_NO_TOOLTIP 1117 #ifndef QT_NO_WHATSTHIS 1131 tab->whatsThis = text;
1147 return tab->whatsThis;
1151 #endif // QT_NO_WHATSTHIS 1185 QRect r = tab->rect;
1206 if (
d->validIndex(
d->currentIndex)
1208 return d->currentIndex;
1210 const int max =
d->tabList.size();
1211 for (
int i = 0; i < max; ++i) {
1212 if (
tabRect(i).contains(position)) {
1232 if (
d->validIndex(
d->currentIndex))
1233 return d->currentIndex;
1241 if (
d->dragInProgress &&
d->pressedIndex != -1)
1244 int oldIndex =
d->currentIndex;
1245 if (
d->validIndex(index) &&
d->currentIndex !=
index) {
1248 d->makeVisible(index);
1249 d->tabList[
index].lastTab = oldIndex;
1250 if (oldIndex >= 0 && oldIndex <
count())
1251 d->layoutTab(oldIndex);
1252 d->layoutTab(index);
1253 #ifndef QT_NO_ACCESSIBILITY 1262 emit selected(index);
1284 if (
d->iconSize.isValid())
1287 return QSize(iconExtent, iconExtent);
1295 d->layoutDirty =
true;
1311 return d->tabList.count();
1323 for (
int i = 0; i <
d->tabList.count(); ++i)
1324 r = r.
united(
d->tabList.at(i).maxRect);
1336 if (!
d->useScrollButtons) {
1338 for (
int i = 0; i <
d->tabList.count(); ++i)
1339 r = r.
united(
d->tabList.at(i).minRect);
1358 ret = text.
left(2) + Ellipses;
1361 ret = text.
left(1) + Ellipses + text.
right(1);
1364 ret = Ellipses + text.
right(2);
1395 opt.
text =
d->tabList.at(index).text;
1404 int widgetWidth = 0;
1405 int widgetHeight = 0;
1426 + widgetWidth + padding,
1475 if (!
d->validIndex(
d->currentIndex))
1477 d->updateMacBorderMetrics();
1485 d->updateMacBorderMetrics();
1496 if (!
d->hoverRect.contains(he->
pos())) {
1497 QRect oldHoverRect =
d->hoverRect;
1498 for (
int i = 0; i <
d->tabList.count(); ++i) {
1501 d->hoverRect =
area;
1511 QRect oldHoverRect =
d->hoverRect;
1515 #ifndef QT_NO_TOOLTIP 1518 if (!tab->toolTip.isEmpty()) {
1519 QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tab->toolTip,
this);
1523 #endif // QT_NO_TOOLTIP 1524 #ifndef QT_NO_WHATSTHIS 1531 if (
const QTabBarPrivate::Tab *tab =
d->at(
d->indexAtPos(static_cast<QHelpEvent*>(event)->pos()))) {
1532 if (!tab->whatsThis.isEmpty()) {
1534 tab->whatsThis,
this);
1538 #endif // QT_NO_WHATSTHIS 1539 #ifndef QT_NO_SHORTCUT 1542 for (
int i = 0; i <
d->tabList.count(); ++i) {
1563 d->makeVisible(
d->currentIndex);
1581 selected =
d->currentIndex;
1582 if (
d->dragInProgress)
1583 selected =
d->pressedIndex;
1585 for (
int i = 0; i <
d->tabList.count(); ++i)
1593 for (
int i = 0; i <
d->tabList.count(); ++i) {
1596 if (
d->paintWithOffsets &&
d->tabList[i].dragOffset != 0) {
1609 || (vertical && tab.
rect.
top() < 0)) {
1626 if (selected >= 0) {
1629 if (
d->paintWithOffsets &&
d->tabList[selected].dragOffset != 0) {
1635 if (!
d->dragInProgress)
1639 d->movingTab->setGeometry(tab.
rect.
adjusted(-taboverlap, 0, taboverlap, 0));
1644 if (
d->leftB->isVisible() && cut >= 0) {
1659 int start =
qMin(from, to);
1661 if (index >= start && index <= end)
1662 index += (from < to) ? -1 : 1;
1676 || !
d->validIndex(from)
1677 || !
d->validIndex(to))
1681 int oldPressedPosition = 0;
1682 if (
d->pressedIndex != -1) {
1684 oldPressedPosition = vertical ?
d->tabList[
d->pressedIndex].rect.y()
1685 :
d->tabList[
d->pressedIndex].rect.x();
1689 int start =
qMin(from, to);
1691 int width = vertical ?
d->tabList[from].rect.height() :
d->tabList[from].rect.width();
1695 for (
int i = start; i <=
end; ++i) {
1699 d->tabList[i].rect.moveTop(
d->tabList[i].rect.y() +
width);
1701 d->tabList[i].rect.moveLeft(
d->tabList[i].rect.x() +
width);
1703 if (rtl && !vertical)
1705 if (
d->tabList[i].dragOffset != 0)
1706 d->tabList[i].dragOffset += (direction *
width);
1711 d->tabList[from].rect.moveTop(
d->tabList[to].rect.bottom() + 1);
1713 d->tabList[from].rect.moveTop(
d->tabList[to].rect.top() -
width);
1716 d->tabList[from].rect.moveLeft(
d->tabList[to].rect.right() + 1);
1718 d->tabList[from].rect.moveLeft(
d->tabList[to].rect.left() -
width);
1722 d->tabList.move(from, to);
1725 for (
int i = 0; i <
d->tabList.count(); ++i)
1726 d->tabList[i].lastTab =
d->calculateNewPosition(from, to,
d->tabList[i].lastTab);
1729 d->currentIndex =
d->calculateNewPosition(from, to,
d->currentIndex);
1732 if (
d->pressedIndex != -1) {
1733 d->pressedIndex =
d->calculateNewPosition(from, to,
d->pressedIndex);
1734 int newPressedPosition = vertical ?
d->tabList[
d->pressedIndex].rect.top() :
d->tabList[
d->pressedIndex].rect.left();
1735 int diff = oldPressedPosition - newPressedPosition;
1739 d->dragStartPosition.setY(
d->dragStartPosition.y() -
diff);
1741 d->dragStartPosition.setX(
d->dragStartPosition.x() -
diff);
1744 d->layoutWidgets(start);
1754 || !validIndex(from)
1758 int preLocation = vertical ? q->tabRect(from).y() : q->tabRect(from).x();
1759 q->setUpdatesEnabled(
false);
1760 q->moveTab(from, to);
1761 q->setUpdatesEnabled(
true);
1762 int postLocation = vertical ? q->tabRect(to).y() : q->tabRect(to).x();
1763 int length = postLocation - preLocation;
1764 tabList[to].dragOffset -= length;
1770 if (!validIndex(index))
1772 tabList[
index].dragOffset = offset;
1787 if (
d->pressedIndex != -1 &&
d->movable)
1788 d->moveTabFinished(
d->pressedIndex);
1790 d->pressedIndex =
d->indexAtPos(event->
pos());
1792 d->previousPressedIndex =
d->pressedIndex;
1794 if (
d->validIndex(
d->pressedIndex)) {
1796 optTabBase.
init(
this);
1803 d->dragStartPosition =
event->pos();
1815 if (
d->pressedIndex != -1
1817 d->moveTabFinished(
d->pressedIndex);
1820 if (!
d->dragInProgress &&
d->pressedIndex != -1) {
1822 d->dragInProgress =
true;
1823 d->setupMovableTab();
1827 int offset = (
event->pos() -
d->dragStartPosition).manhattanLength();
1830 &&
d->validIndex(
d->pressedIndex)) {
1834 dragDistance = (
event->pos().y() -
d->dragStartPosition.y());
1836 dragDistance = (
event->pos().x() -
d->dragStartPosition.x());
1838 d->tabList[
d->pressedIndex].dragOffset = dragDistance;
1842 startingRect.
moveTop(startingRect.
y() + dragDistance);
1844 startingRect.
moveLeft(startingRect.
x() + dragDistance);
1847 if (dragDistance < 0)
1852 if (overIndex !=
d->pressedIndex && overIndex != -1) {
1856 if (dragDistance < 0) {
1860 for (
int i =
d->pressedIndex;
1861 offset > 0 ? i < overIndex : i > overIndex;
1864 int needsToBeOver = (vertical ? overIndexRect.
height() : overIndexRect.
width()) / 2;
1865 if (dragDistance > needsToBeOver)
1866 d->slide(i + offset,
d->pressedIndex);
1870 d->layoutTab(
d->pressedIndex);
1876 int newPressedIndex =
d->indexAtPos(event->
pos());
1877 if (
d->pressedIndex == -1 &&
d->previousPressedIndex == newPressedIndex) {
1878 d->pressedIndex =
d->previousPressedIndex;
1880 }
else if(
d->pressedIndex != newPressedIndex) {
1881 d->pressedIndex = -1;
1892 optTabBase.
init(
this);
1903 QRect grabRect = q->tabRect(pressedIndex);
1904 grabRect.
adjust(-taboverlap, 0, taboverlap, 0);
1912 q->initStyleOption(&tab, pressedIndex);
1919 movingTab->setPalette(pal);
1920 movingTab->setGeometry(grabRect);
1921 movingTab->setAutoFillBackground(
true);
1925 if (tabList[pressedIndex].leftWidget)
1926 tabList[pressedIndex].leftWidget->raise();
1927 if (tabList[pressedIndex].rightWidget)
1928 tabList[pressedIndex].rightWidget->raise();
1933 movingTab->setVisible(
true);
1939 bool cleanup = (pressedIndex ==
index) || (pressedIndex == -1) || !validIndex(index);
1940 bool allAnimationsFinished =
true;
1941 #ifndef QT_NO_ANIMATION 1942 for(
int i = 0; allAnimationsFinished && i < tabList.count(); ++i) {
1943 const Tab &t = tabList.at(i);
1945 allAnimationsFinished =
false;
1947 #endif //QT_NO_ANIMATION 1948 if (allAnimationsFinished && cleanup) {
1950 movingTab->setVisible(
false);
1951 for (
int i = 0; i < tabList.count(); ++i) {
1954 if (pressedIndex != -1 &&
movable) {
1956 dragInProgress =
false;
1957 dragStartPosition =
QPoint();
1961 if (!validIndex(index))
1963 tabList[
index].dragOffset = 0;
1978 d->previousPressedIndex = -1;
1980 if (
d->movable &&
d->dragInProgress &&
d->validIndex(
d->pressedIndex)) {
1981 int length =
d->tabList[
d->pressedIndex].dragOffset;
1987 d->tabList[
d->pressedIndex].startAnimation(
d, duration);
1988 d->dragInProgress =
false;
1989 d->movingTab->setVisible(
false);
1990 d->dragStartPosition =
QPoint();
1993 int i =
d->indexAtPos(event->
pos()) ==
d->pressedIndex ?
d->pressedIndex : -1;
1994 d->pressedIndex = -1;
1997 optTabBase.documentMode =
d->documentMode;
2012 d->setCurrentNextEnabledIndex(offset);
2017 #ifndef QT_NO_WHEELEVENT 2021 int offset =
event->delta() > 0 ? -1 : 1;
2022 d->setCurrentNextEnabledIndex(offset);
2025 #endif //QT_NO_WHEELEVENT 2031 if (tabList.at(
index).enabled) {
2032 q->setCurrentIndex(
index);
2044 if (!
d->elideModeSetByUser)
2046 if (!
d->useScrollButtonsSetByUser)
2074 return d->elideMode;
2080 d->elideMode = mode;
2081 d->elideModeSetByUser =
true;
2103 return d_func()->useScrollButtons;
2109 d->useScrollButtonsSetByUser =
true;
2110 if (
d->useScrollButtons == useButtons)
2112 d->useScrollButtons = useButtons;
2155 return d->closeButtonOnTabs;
2161 if (
d->closeButtonOnTabs == closable)
2163 d->closeButtonOnTabs = closable;
2166 for (
int i = 0; i <
d->tabList.count(); ++i) {
2167 if (closeSide ==
LeftSide &&
d->tabList[i].leftWidget) {
2168 d->tabList[i].leftWidget->deleteLater();
2169 d->tabList[i].leftWidget = 0;
2171 if (closeSide ==
RightSide &&
d->tabList[i].rightWidget) {
2172 d->tabList[i].rightWidget->deleteLater();
2173 d->tabList[i].rightWidget = 0;
2177 bool newButtons =
false;
2178 for (
int i = 0; i <
d->tabList.count(); ++i) {
2243 return d->selectionBehaviorOnRemove;
2249 d->selectionBehaviorOnRemove = behavior;
2268 return d->expanding;
2274 if (
d->expanding == enabled)
2322 return d_func()->documentMode;
2330 d->updateMacBorderMetrics();
2349 if (index < 0 || index >=
d->tabList.count())
2358 if (
d->tabList[index].leftWidget)
2359 d->tabList[
index].leftWidget->hide();
2362 if (
d->tabList[index].rightWidget)
2363 d->tabList[
index].rightWidget->hide();
2378 if (index < 0 || index >=
d->tabList.count())
2381 return d->tabList.at(index).leftWidget;
2383 return d->tabList.at(index).rightWidget;
2390 #ifndef QT_NO_CURSOR 2393 #ifndef QT_NO_TOOLTIP 2404 return QSize(width, height);
2434 if (
const QTabBar *tb = qobject_cast<const QTabBar *>(
parent())) {
2435 int index = tb->currentIndex();
2437 if (tb->tabButton(index, position) ==
this)
2446 #include "moc_qtabbar.cpp" 2448 #endif // QT_NO_TABBAR The QVariant class acts like a union for the most common Qt data types.
void setDrawBase(bool drawTheBase)
void moveTab(int from, int to)
Moves the item at index position from to index position to.
T qobject_cast(QObject *object)
The QPainter class performs low-level painting on widgets and other paint devices.
void moveTab(int index, int offset)
em>Reimplemented Function
The QColor class provides colors based on RGB, HSV or CMYK values.
void showEvent(QShowEvent *)
em>Reimplemented Function
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object's accessibility information.
SelectionBehavior selectionBehaviorOnRemove() const
The QKeyEvent class describes a key event.
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
virtual void tabRemoved(int index)
This virtual handler is called after a tab was removed from position index.
bool validIndex(int index) const
bool event(QEvent *)
em>Reimplemented Function
void updateMacBorderMetrics()
void currentChanged(int index)
This signal is emitted when the tab bar's current tab changes.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
The QFontMetrics class provides font metrics information.
#define QT_END_NAMESPACE
This macro expands to.
void moveTabFinished(int index)
em>Reimplemented Function
QPointer< QWidget > widget
void drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
Use the widget's style to draw a control element ce specified by QStyleOption option.
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate...
The QStyleOptionTabV2 class is used to describe the parameters necessary for drawing a tabs in Qt 4...
QStyle::State state
the style flags that are used when drawing the control
QColor tabTextColor(int index) const
Returns the text color of the tab with the given index, or a invalid color if index is out of range...
void mouseReleaseEvent(QMouseEvent *)
em>Reimplemented Function
The QWheelEvent class contains parameters that describe a wheel event.
static QSize globalStrut()
QVariant tabData(int index) const
Returns the data of the tab at position index, or a null variant if index is out of range...
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
bool isTabEnabled(int index) const
Returns true if the tab at position index is enabled; otherwise returns false.
QRect united(const QRect &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
QSize minimumSizeHint() const
The QHoverEvent class contains parameters that describe a mouse event.
int length() const
Returns the number of characters in this string.
ButtonPosition
This enum type lists the location of the widget on a tab.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
QTabBar(QWidget *parent=0)
Creates a new tab bar with the given parent.
void hideEvent(QHideEvent *)
em>Reimplemented Function
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
void setCurrentNextEnabledIndex(int offset)
em>Reimplemented Function
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
void tabMoved(int from, int to)
This signal is emitted when the tab has moved the tab at index position from to index position to...
int left() const
Returns the x-coordinate of the rectangle's left edge.
int width() const
Returns the width of the rectangle.
void setCurrentIndex(int index)
void init(const QWidget *w)
Use initFrom(widget) instead.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
TabPosition position
the position of the tab in the tab bar
int indexAtPos(const QPoint &p) const
static QStyle * style()
Returns the application's style object.
The QTabBar class provides a tab bar, e.g.
bool tabsClosable() const
int height() const
Returns the height of the rectangle.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
void mousePressEvent(QMouseEvent *)
em>Reimplemented Function
Q_DECL_CONSTEXPR T qAbs(const T &t)
The QObject class is the base class of all Qt objects.
bool empty() const
This function is provided for STL compatibility.
QSize sizeHint() const
em>Reimplemented Function
void removeTab(int index)
Removes the tab at position index.
QWidget * tabButton(int index, ButtonPosition position) const
Returns the widget set a tab index and position or 0 if one is not set.
QTabBar::Shape shape
the tab shape used to draw the tab; by default QTabBar::RoundedNorth
virtual void tabLayoutChange()
This virtual handler is called whenever the tab layout changes.
void setTabText(int index, const QString &text)
Sets the text of the tab at position index to text.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void setTabButton(int index, ButtonPosition position, QWidget *widget)
Sets widget on the tab index.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
OSWindowRef qt_mac_window_for(const QWidget *)
virtual void tabInserted(int index)
This virtual handler is called after a new tab was added or inserted at position index.
QRect tabBarRect
the rectangle containing all the tabs
const QPoint & oldPos() const
Returns the previous position of the mouse cursor, relative to the widget that received the event...
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
int key() const
Returns the code of the key that was pressed or released.
int width() const
Returns the width.
#define QT_BEGIN_NAMESPACE
This macro expands to.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Shape
This enum type lists the built-in shapes supported by QTabBar.
bool documentMode
whether the tabbar is in document mode.
void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt)
Use the widget's style to draw a primitive element pe specified by QStyleOption option.
void setTabToolTip(int index, const QString &tip)
Sets the tool tip of the tab at position index to tip.
void setTabsClosable(bool closable)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=0) const
Returns the size in pixels of text.
The QStyleOption class stores the parameters used by QStyle functions.
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...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
#define ANIMATION_DURATION
void setExpanding(bool enabled)
void initFrom(const QWidget *w)
int insertTab(int index, const QString &text)
Inserts a new tab with text text at position index.
QSize size() const
Returns the size of the rectangle.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
The QHideEvent class provides an event which is sent after a widget is hidden.
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
void setDocumentMode(bool set)
void setShape(Shape shape)
void setElideMode(Qt::TextElideMode)
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QResizeEvent class contains event parameters for resize events.
const char * styleHint(const QFontDef &request)
QTabBarPrivate::Tab::TabBarAnimation * animation
void setTabTextColor(int index, const QColor &color)
Sets the color of the text in the tab with the given index to the specified color.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
void slide(int from, int to)
void wheelEvent(QWheelEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive wheel events for t...
int row
which row the tab is currently in
int calculateNewPosition(int from, int to, int index) const
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
void setTabWhatsThis(int index, const QString &text)
Sets the What's This help text of the tab at position index to text.
static int startDragDistance()
QSize minimumTabSizeHint(int index)
bool documentMode() const
The QShowEvent class provides an event that is sent when a widget is shown.
void setTabEnabled(int index, bool)
If enabled is true then the tab at position index is enabled; otherwise the item at position index is...
CornerWidgets cornerWidgets
an OR combination of CornerWidget values indicating the corner widgets of the tab bar ...
Qt::MouseButton button() const
Returns the button that caused the event.
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
void setMovable(bool movable)
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
QSize rightButtonSize
the size for the right widget on the tab.
static QWidget * parentWidget(const QWidget *w)
static bool isActive()
Returns true if an accessibility implementation has been requested during the runtime of the applicat...
The QMouseEvent class contains parameters that describe a mouse event.
SelectionBehavior
This enum type lists the behavior of QTabBar when a tab is removed and the tab being removed is also ...
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
QPoint topRight() const
Returns the position of the rectangle's top-right corner.
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 QStyleOptionTabBarBaseV2 class is used to describe the base of a tab bar, i.e.
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
void mouseMoveEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
QPalette palette
the palette that should be used when painting the control
void setTabData(int index, const QVariant &data)
Sets the data of the tab at position index to data.
QString text
the text of the tab
int shortcutId()
This is an overloaded member function, provided for convenience. It differs from the above function o...
SelectedPosition selectedPosition
the position of the selected tab in relation to this tab
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
int top() const
Returns the y-coordinate of the rectangle's top edge.
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
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.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
int right() const
Returns the x-coordinate of the rectangle's right edge.
QString tabText(int index) const
Returns the text of the tab at position index, or an empty string if index is out of range...
void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
int y() const
Returns the y-coordinate of the rectangle's top edge.
QString tabToolTip(int index) const
Returns the tool tip of the tab at position index, or an empty string if index is out of range...
void keyPressEvent(QKeyEvent *)
em>Reimplemented Function
static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
int x() const
Returns the x-coordinate of the rectangle's left edge.
QRect selectedTabRect
the rectangle containing the selected tab
QObject * parent() const
Returns a pointer to the parent object.
bool movable
This property holds whether the user can move the tabs within the tabbar area.
void initStyleOption(QStyleOptionTab *option, int tabIndex) const
Initialize option with the values from the tab at tabIndex.
static QString computeElidedText(Qt::TextElideMode mode, const QString &text)
The QPoint class defines a point in the plane using integer precision.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
QSize iconSize
the size for the icons
The QStyleOptionTabV3 class is used to describe the parameters necessary for drawing a tabs in Qt 4...
int height() const
Returns the height.
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
void setSelectionBehaviorOnRemove(SelectionBehavior behavior)
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
void layoutWidgets(int start=0)
Qt::TextElideMode elideMode
int y() const
Returns the y coordinate of this point.
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...
void initFrom(const QWidget *widget)
Initializes the painters pen, background and font to the same as the given widget.
The QPixmap class is an off-screen image representation that can be used as a paint device...
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
QIcon icon
the icon for the tab
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
virtual QSize tabSizeHint(int index) const
Returns the size hint for the tab at position index.
int tabAt(const QPoint &pos) const
void layoutTab(int index)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget...
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
The QSize class defines the size of a two-dimensional object using integer point precision.
void setTabIcon(int index, const QIcon &icon)
Sets the icon of the tab at position index to icon.
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
void setUsesScrollButtons(bool useButtons)
int x() const
Returns the x coordinate of this point.
bool isValid() const
Returns true if the color is valid; otherwise returns false.
Qt::TextElideMode elideMode() const
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
QSize leftButtonSize
the size for the left widget on the tab.
int height() const
Returns the height of the font.
static void showText(const QPoint &pos, const QString &text, QWidget *w=0)
Shows text as a "What's This?" window, at global position pos.
void setIconSize(const QSize &size)
The QPaintEvent class contains event parameters for paint events.
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
static const KeyPair *const end
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
void resizeEvent(QResizeEvent *)
em>Reimplemented Function
int addTab(const QString &text)
Adds a new tab with text text.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
~QTabBar()
Destroys the tab bar.
QRect rect
the area that should be used for various calculations and painting
bool usesScrollButtons() const
static bool verticalTabs(QTabBar::Shape shape)
QString tabWhatsThis(int index) const
Returns the What's This help text of the tab at position index, or an empty string if index is out of...
void makeVisible(int index)
void qt_mac_updateContentBorderMetricts(void *window, const ::HIContentBorderMetrics &metrics)
static int area(const QSize &s)
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
Qt::LayoutDirection direction
The QPalette class contains color groups for each widget state.
QIcon tabIcon(int index) const
Returns the icon of the tab at position index, or a null icon if index is out of range.
The QIcon class provides scalable icons in different modes and states.