📄 qtabwidget.cpp
字号:
Possible values for this property are QTabWidget::Rounded (default) or QTabWidget::Triangular. \sa TabShape*/QTabWidget::TabShape QTabWidget::tabShape() const{ Q_D(const QTabWidget); return d->shape;}void QTabWidget::setTabShape(TabShape s){ Q_D(QTabWidget); if (d->shape == s) return; d->shape = s; d->updateTabBarPosition();}/*! \reimp */bool QTabWidget::event(QEvent *ev){ if (ev->type() == QEvent::LayoutRequest) setUpLayout(); return QWidget::event(ev);}/*! \reimp */void QTabWidget::changeEvent(QEvent *ev){ if (ev->type() == QEvent::StyleChange#ifdef Q_WS_MAC || ev->type() == QEvent::MacSizeChange#endif ) setUpLayout(); QWidget::changeEvent(ev);}/*! \reimp */void QTabWidget::keyPressEvent(QKeyEvent *e){ Q_D(QTabWidget); if (((e->key() == Qt::Key_Tab || e->key() == Qt::Key_Backtab) && count() > 1 && e->modifiers() & Qt::ControlModifier)#ifdef QT_KEYPAD_NAVIGATION || QApplication::keypadNavigationEnabled() && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right) && count() > 1#endif ) { int pageCount = d->tabs->count(); int page = currentIndex(); int dx = (e->key() == Qt::Key_Backtab || e->modifiers() & Qt::ShiftModifier) ? -1 : 1;#ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled() && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right)) dx = e->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1;#endif for (int pass = 0; pass < pageCount; ++pass) { page+=dx; if (page < 0#ifdef QT_KEYPAD_NAVIGATION && !e->isAutoRepeat()#endif ) { page = count() - 1; } else if (page >= pageCount#ifdef QT_KEYPAD_NAVIGATION && !e->isAutoRepeat()#endif ) { page = 0; } if (d->tabs->isTabEnabled(page)) { setCurrentIndex(page); break; } } if (!qApp->focusWidget()) d->tabs->setFocus(); } else { e->ignore(); }}/*! Returns the tab page at index position \a index or 0 if the \a index is out of range.*/QWidget *QTabWidget::widget(int index) const{ Q_D(const QTabWidget); return d->stack->widget(index);}/*! \property QTabWidget::count \brief the number of tabs in the tab bar*/int QTabWidget::count() const{ Q_D(const QTabWidget); return d->tabs->count();}#ifndef QT_NO_TOOLTIP/*! Sets the tab tool tip for the page at position \a index to \a tip. \sa tabToolTip()*/void QTabWidget::setTabToolTip(int index, const QString & tip){ Q_D(QTabWidget); d->tabs->setTabToolTip(index, tip);}/*! Returns the tab tool tip for the page at position \a index or an empty string if no tool tip has been set. \sa setTabToolTip()*/QString QTabWidget::tabToolTip(int index) const{ Q_D(const QTabWidget); return d->tabs->tabToolTip(index);}#endif // QT_NO_TOOLTIP#ifndef QT_NO_WHATSTHIS/*! \since 4.1 Sets the What's This help text for the page at position \a index to \a text.*/void QTabWidget::setTabWhatsThis(int index, const QString &text){ Q_D(QTabWidget); d->tabs->setTabWhatsThis(index, text);}/*! \since 4.1 Returns the What's This help text for the page at position \a index, or an empty string if no help text has been set.*/QString QTabWidget::tabWhatsThis(int index) const{ Q_D(const QTabWidget); return d->tabs->tabWhatsThis(index);}#endif // QT_NO_WHATSTHIS/*! This virtual handler is called after a new tab was added or inserted at position \a index. \sa tabRemoved() */void QTabWidget::tabInserted(int index){ Q_UNUSED(index)}/*! This virtual handler is called after a tab was removed from position \a index. \sa tabInserted() */void QTabWidget::tabRemoved(int index){ Q_UNUSED(index)}/*! \fn void QTabWidget::paintEvent(QPaintEvent *event) Paints the tab widget's tab bar in response to the paint \a event.*/void QTabWidget::paintEvent(QPaintEvent *){ Q_D(QTabWidget); QStylePainter p(this); QStyleOptionTabWidgetFrame opt; initStyleOption(&opt); opt.rect = d->panelRect; p.drawPrimitive(QStyle::PE_FrameTabWidget, opt);}/*! \property QTabWidget::iconSize \brief 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. \sa QTabBar::iconSize*/QSize QTabWidget::iconSize() const{ return d_func()->tabs->iconSize();}void QTabWidget::setIconSize(const QSize &size){ d_func()->tabs->setIconSize(size);}/*! \property QTabWidget::elideMode \brief 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. \sa QTabBar::elideMode usesScrollButtons QStyle::SH_TabBar_ElideMode*/Qt::TextElideMode QTabWidget::elideMode() const{ return d_func()->tabs->elideMode();}void QTabWidget::setElideMode(Qt::TextElideMode mode){ d_func()->tabs->setElideMode(mode);}/*! \property QTabWidget::usesScrollButtons \brief 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 it's size or to add buttons that allow you to scroll through the tabs. By default the value is style dependant. \sa elideMode QTabBar::usesScrollButtons QStyle::SH_TabBar_PreferNoArrows*/bool QTabWidget::usesScrollButtons() const{ return d_func()->tabs->usesScrollButtons();}void QTabWidget::setUsesScrollButtons(bool useButtons){ d_func()->tabs->setUsesScrollButtons(useButtons);}/*! Removes all the pages, but does not delete them. Calling this function is equivalent to calling removeTab() until the tab widget is empty.*/void QTabWidget::clear(){ // ### optimize by introduce QStackedLayout::clear() while (count()) removeTab(0);}/*! \fn void QTabWidget::insertTab(QWidget *widget, const QString &label, int index) Use insertTab(index, widget, label) instead.*//*! \fn void QTabWidget::insertTab(QWidget *widget, const QIcon& icon, const QString &label, int index) Use insertTab(index, widget, icon, label) instead.*//*! \fn void QTabWidget::changeTab(QWidget *widget, const QString &label) Use setTabText() instead.*//*! \fn void QTabWidget::changeTab(QWidget *widget, const QIcon& icon, const QString &label) Use setTabText() and setTabIcon() instead.*//*! \fn bool QTabWidget::isTabEnabled( QWidget *widget) const Use isTabEnabled(tabWidget->indexOf(widget)) instead.*//*! \fn void QTabWidget::setTabEnabled(QWidget *widget, bool b) Use isTabEnabled(tabWidget->indexOf(widget), b) instead.*//*! \fn QString QTabWidget::tabLabel(QWidget *widget) const Use tabText(tabWidget->indexOf(widget)) instead.*//*! \fn void QTabWidget::setTabLabel(QWidget *widget, const QString &label) Use setTabText(tabWidget->indexOf(widget), label) instead.*//*! \fn QIcon QTabWidget::tabIconSet(QWidget * widget) const Use tabIcon(tabWidget->indexOf(widget)) instead.*//*! \fn void QTabWidget::setTabIconSet(QWidget * widget, const QIcon & icon) Use setTabIcon(tabWidget->indexOf(widget), icon) instead.*//*! \fn void QTabWidget::removeTabToolTip(QWidget * widget) Use setTabToolTip(tabWidget->indexOf(widget), QString()) instead.*//*! \fn void QTabWidget::setTabToolTip(QWidget * widget, const QString & tip) Use setTabToolTip(tabWidget->indexOf(widget), tip) instead.*//*! \fn QString QTabWidget::tabToolTip(QWidget * widget) const Use tabToolTip(tabWidget->indexOf(widget)) instead.*//*! \fn QWidget * QTabWidget::currentPage() const Use currentWidget() instead.*//*! \fn QWidget *QTabWidget::page(int index) const Use widget() instead.*//*! \fn QString QTabWidget::label(int index) const Use tabText() instead.*//*! \fn int QTabWidget::currentPageIndex() const Use currentIndex() instead.*//*! \fn int QTabWidget::margin() const This function is kept only to make old code compile. This functionality is no longer supported by QTabWidget. \sa contentsRect(), setContentsMargins()*//*! \fn void QTabWidget::setMargin(int margin) This function is kept only to make old code compile. This functionality is no longer supported by QTabWidget. \sa contentsRect(), setContentsMargins()*//*! \fn void QTabWidget::setCurrentPage(int index) Use setCurrentIndex() instead.*//*! \fn void QTabWidget::showPage(QWidget *widget) Use setCurrentIndex(indexOf(widget)) instead.*//*! \fn void QTabWidget::removePage(QWidget *widget) Use removeTab(indexOf(widget)) instead.*//*! \fn void QTabWidget::currentChanged(QWidget *widget) Use currentChanged(int) instead.*/#include "moc_qtabwidget.cpp"#endif //QT_NO_TABWIDGET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -