File indexing completed on 2025-01-18 10:09:39
0001
0002
0003
0004 #ifndef QTABWIDGET_H
0005 #define QTABWIDGET_H
0006
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qwidget.h>
0009 #include <QtGui/qicon.h>
0010
0011 QT_REQUIRE_CONFIG(tabwidget);
0012
0013 QT_BEGIN_NAMESPACE
0014
0015 class QTabBar;
0016 class QTabWidgetPrivate;
0017 class QStyleOptionTabWidgetFrame;
0018
0019 class Q_WIDGETS_EXPORT QTabWidget : public QWidget
0020 {
0021 Q_OBJECT
0022 Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition)
0023 Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape)
0024 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
0025 Q_PROPERTY(int count READ count)
0026 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
0027 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
0028 Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
0029 Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
0030 Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
0031 Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
0032 Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide WRITE setTabBarAutoHide)
0033
0034 public:
0035 explicit QTabWidget(QWidget *parent = nullptr);
0036 ~QTabWidget();
0037
0038 int addTab(QWidget *widget, const QString &);
0039 int addTab(QWidget *widget, const QIcon& icon, const QString &label);
0040
0041 int insertTab(int index, QWidget *widget, const QString &);
0042 int insertTab(int index, QWidget *widget, const QIcon& icon, const QString &label);
0043
0044 void removeTab(int index);
0045
0046 bool isTabEnabled(int index) const;
0047 void setTabEnabled(int index, bool enabled);
0048
0049 bool isTabVisible(int index) const;
0050 void setTabVisible(int index, bool visible);
0051
0052 QString tabText(int index) const;
0053 void setTabText(int index, const QString &text);
0054
0055 QIcon tabIcon(int index) const;
0056 void setTabIcon(int index, const QIcon & icon);
0057
0058 #if QT_CONFIG(tooltip)
0059 void setTabToolTip(int index, const QString & tip);
0060 QString tabToolTip(int index) const;
0061 #endif
0062
0063 #if QT_CONFIG(whatsthis)
0064 void setTabWhatsThis(int index, const QString &text);
0065 QString tabWhatsThis(int index) const;
0066 #endif
0067
0068 int currentIndex() const;
0069 QWidget *currentWidget() const;
0070 QWidget *widget(int index) const;
0071 int indexOf(const QWidget *widget) const;
0072 int count() const;
0073
0074 enum TabPosition { North, South, West, East };
0075 Q_ENUM(TabPosition)
0076 TabPosition tabPosition() const;
0077 void setTabPosition(TabPosition position);
0078
0079 bool tabsClosable() const;
0080 void setTabsClosable(bool closeable);
0081
0082 bool isMovable() const;
0083 void setMovable(bool movable);
0084
0085 enum TabShape { Rounded, Triangular };
0086 Q_ENUM(TabShape)
0087 TabShape tabShape() const;
0088 void setTabShape(TabShape s);
0089
0090 QSize sizeHint() const override;
0091 QSize minimumSizeHint() const override;
0092 int heightForWidth(int width) const override;
0093 bool hasHeightForWidth() const override;
0094
0095 void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
0096 QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
0097
0098 Qt::TextElideMode elideMode() const;
0099 void setElideMode(Qt::TextElideMode mode);
0100
0101 QSize iconSize() const;
0102 void setIconSize(const QSize &size);
0103
0104 bool usesScrollButtons() const;
0105 void setUsesScrollButtons(bool useButtons);
0106
0107 bool documentMode() const;
0108 void setDocumentMode(bool set);
0109
0110 bool tabBarAutoHide() const;
0111 void setTabBarAutoHide(bool enabled);
0112
0113 void clear();
0114
0115 QTabBar* tabBar() const;
0116
0117 public Q_SLOTS:
0118 void setCurrentIndex(int index);
0119 void setCurrentWidget(QWidget *widget);
0120
0121 Q_SIGNALS:
0122 void currentChanged(int index);
0123 void tabCloseRequested(int index);
0124 void tabBarClicked(int index);
0125 void tabBarDoubleClicked(int index);
0126
0127 protected:
0128 virtual void tabInserted(int index);
0129 virtual void tabRemoved(int index);
0130
0131 void showEvent(QShowEvent *) override;
0132 void resizeEvent(QResizeEvent *) override;
0133 void keyPressEvent(QKeyEvent *) override;
0134 void paintEvent(QPaintEvent *) override;
0135 void setTabBar(QTabBar *);
0136 void changeEvent(QEvent *) override;
0137 bool event(QEvent *) override;
0138 virtual void initStyleOption(QStyleOptionTabWidgetFrame *option) const;
0139
0140
0141 private:
0142 Q_DECLARE_PRIVATE(QTabWidget)
0143 Q_DISABLE_COPY(QTabWidget)
0144 void setUpLayout(bool = false);
0145 };
0146
0147 QT_END_NAMESPACE
0148
0149 #endif