44 #ifndef QT_NO_TABWIDGET 45 #include "private/qwidget_p.h" 46 #include "private/qtabbar_p.h" 252 q->setTabBar(tabBar);
256 #ifdef QT_KEYPAD_NAVIGATION 257 if (QApplication::keypadNavigationEnabled())
262 q->setFocusProxy(
tabs);
263 q->setTabPosition(static_cast<QTabWidget::TabPosition> (q->style()->styleHint(
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());
310 if (
d->rightCornerWidget) {
311 const QSize rightCornerSizeHint =
d->rightCornerWidget->sizeHint();
312 const QSize bounds(rightCornerSizeHint.
width(), t.height() - exth);
318 if (
d->leftCornerWidget) {
319 const QSize leftCornerSizeHint =
d->leftCornerWidget->sizeHint();
320 const QSize bounds(leftCornerSizeHint.
width(), t.height() - exth);
348 QRect tbRect = tabBar()->geometry();
349 QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex());
350 tabframe->tabBarRect = tbRect;
352 tabframe->selectedTabRect = selectedTabRect;
425 return insertTab(-1, child, icon, label);
483 index =
d->stack->insertWidget(index, w);
484 d->tabs->insertTab(index, icon, label);
507 d->tabs->setTabText(index, label);
518 return d->tabs->tabText(index);
532 d->tabs->setTabIcon(index, icon);
543 return d->tabs->tabIcon(index);
555 return d->tabs->isTabEnabled(index);
575 d->tabs->setTabEnabled(index, enable);
609 if (
d->rightCornerWidget)
610 d->rightCornerWidget->hide();
613 if (
d->leftCornerWidget)
614 d->leftCornerWidget->hide();
627 return d->rightCornerWidget;
628 return d->leftCornerWidget;
640 if (
QWidget *w =
d->stack->widget(index))
641 d->stack->removeWidget(w);
655 return d->stack->currentWidget();
667 d->tabs->setCurrentIndex(
indexOf(widget));
687 return d->tabs->currentIndex();
693 d->tabs->setCurrentIndex(index);
704 return d->stack->indexOf(w);
737 this,
SLOT(_q_showTab(
int)));
739 this,
SLOT(_q_tabMoved(
int,
int)));
740 if (
d->tabs->tabsClosable())
767 if (index < stack->
count() && index >= 0)
768 stack->setCurrentIndex(index);
769 emit q->currentChanged(index);
771 emit q->selected(q->tabText(index));
772 emit q->currentChanged(stack->widget(index));
779 tabs->removeTab(index);
781 q->tabRemoved(index);
786 stack->blockSignals(
true);
787 QWidget *w = stack->widget(from);
788 stack->removeWidget(w);
789 stack->insertWidget(to, w);
801 if (onlyCheck && !
d->dirty)
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);
852 QSize lc(0, 0), rc(0, 0);
857 if (
d->leftCornerWidget)
858 lc =
d->leftCornerWidget->sizeHint();
859 if(
d->rightCornerWidget)
860 rc =
d->rightCornerWidget->sizeHint();
865 QSize s(
d->stack->sizeHint());
866 QSize t(
d->tabs->sizeHint());
890 QSize lc(0, 0), rc(0, 0);
892 if(
d->leftCornerWidget)
893 lc =
d->leftCornerWidget->minimumSizeHint();
894 if(
d->rightCornerWidget)
895 rc =
d->rightCornerWidget->minimumSizeHint();
900 QSize s(
d->stack->minimumSizeHint());
901 QSize t(
d->tabs->minimumSizeHint());
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();
937 QSize t(
d->tabs->sizeHint());
944 const bool tabIsHorizontal = (
d->pos ==
North ||
d->pos ==
South);
945 const int contentsWidth = width - padding.
width();
946 int stackWidth = contentsWidth;
947 if (!tabIsHorizontal)
950 int stackHeight =
d->stack->heightForWidth(stackWidth);
951 QSize s(stackWidth, stackHeight);
1016 d->updateTabBarPosition();
1098 d->updateTabBarPosition();
1134 #ifdef QT_KEYPAD_NAVIGATION
1138 int pageCount =
d->tabs->count();
1141 #ifdef QT_KEYPAD_NAVIGATION 1145 for (
int pass = 0; pass < pageCount; ++pass) {
1148 #ifdef QT_KEYPAD_NAVIGATION
1153 }
else if (page >= pageCount
1154 #ifdef QT_KEYPAD_NAVIGATION
1160 if (
d->tabs->isTabEnabled(page)) {
1166 d->tabs->setFocus();
1179 return d->stack->widget(index);
1194 return d->tabs->count();
1197 #ifndef QT_NO_TOOLTIP 1206 d->tabs->setTabToolTip(index, tip);
1218 return d->tabs->tabToolTip(index);
1220 #endif // QT_NO_TOOLTIP 1222 #ifndef QT_NO_WHATSTHIS 1235 d->tabs->setTabWhatsThis(index, text);
1250 return d->tabs->tabWhatsThis(index);
1252 #endif // QT_NO_WHATSTHIS 1306 opt.
rect =
d->panelRect;
1326 return d_func()->tabs->iconSize();
1331 d_func()->tabs->setIconSize(size);
1351 return d_func()->tabs->elideMode();
1356 d_func()->tabs->setElideMode(mode);
1377 return d_func()->tabs->usesScrollButtons();
1382 d_func()->tabs->setUsesScrollButtons(useButtons);
1403 return d->tabs->documentMode();
1409 d->tabs->setDocumentMode(enabled);
1410 d->tabs->setExpanding(!enabled);
1411 d->tabs->setDrawBase(enabled);
1590 #include "moc_qtabwidget.cpp" 1592 #endif //QT_NO_TABWIDGET void setDrawBase(bool drawTheBase)
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
The QKeyEvent class describes a key event.
#define QT_END_NAMESPACE
This macro expands to.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate...
QStyle::State state
the style flags that are used when drawing the control
static QSize globalStrut()
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QTabBar class provides a tab bar, e.g.
The QString class provides a Unicode character string.
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool tabsClosable
Whether or not a tab bar should place close buttons on each tab.
void setObjectName(const QString &name)
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
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.
bool hasHeightForWidth() const
void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt)
Use the widget's style to draw a primitive element pe specified by QStyleOption option.
void setTabsClosable(bool closable)
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...
void setExpanding(bool enabled)
void initFrom(const QWidget *w)
The QResizeEvent class contains event parameters for resize events.
The QShowEvent class provides an event that is sent when a widget is shown.
void setMovable(bool movable)
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
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 QStyleOptionTabBarBaseV2 class is used to describe the base of a tab bar, i.e.
QPalette palette
the palette that should be used when painting the control
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.
#define Q_DECLARE_PUBLIC(Class)
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.
int y() const
Returns the y-coordinate of the rectangle's top edge.
static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
int x() const
Returns the x-coordinate of the rectangle's left edge.
QObject * parent() const
Returns a pointer to the parent object.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
bool isAutoRepeat() const
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initia...
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget...
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 moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.
The QPaintEvent class contains event parameters for paint events.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QRect rect
the area that should be used for various calculations and painting
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
The QIcon class provides scalable icons in different modes and states.