本文整理汇总了C++中QTabBar::expanding方法的典型用法代码示例。如果您正苦于以下问题:C++ QTabBar::expanding方法的具体用法?C++ QTabBar::expanding怎么用?C++ QTabBar::expanding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTabBar
的用法示例。
在下文中一共展示了QTabBar::expanding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
});
QLayout *layout;
switch (tabBar.shape()) {
case QTabBar::RoundedEast:
case QTabBar::TriangularEast:
tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
layout = new QHBoxLayout(&widget);
layout->addWidget(&stackedWidget);
layout->addWidget(&tabBar);
break;
case QTabBar::RoundedWest:
case QTabBar::TriangularWest:
tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
layout = new QHBoxLayout(&widget);
layout->addWidget(&tabBar);
layout->addWidget(&stackedWidget);
break;
case QTabBar::RoundedNorth:
case QTabBar::TriangularNorth:
tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
layout = new QVBoxLayout(&widget);
layout->addWidget(&tabBar);
layout->addWidget(&stackedWidget);
break;
case QTabBar::RoundedSouth:
case QTabBar::TriangularSouth:
tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
layout = new QVBoxLayout(&widget);
layout->addWidget(&stackedWidget);
layout->addWidget(&tabBar);
break;
}
TabBarForm form;
layout->addWidget(&form);
layout->setAlignment(&form, Qt::AlignHCenter);
form.ui->documentModeButton->setChecked(tabBar.documentMode());
QObject::connect(form.ui->documentModeButton, &QCheckBox::toggled, [&] {
tabBar.setDocumentMode(form.ui->documentModeButton->isChecked());
// QMacStyle (and maybe other styles) requires a re-polish to get the right font
QApplication::sendEvent(&tabBar, new QEvent(QEvent::ThemeChange));
});
form.ui->movableTabsButton->setChecked(tabBar.isMovable());
QObject::connect(form.ui->movableTabsButton, &QCheckBox::toggled, [&] {
tabBar.setMovable(form.ui->movableTabsButton->isChecked());
tabBar.update();
});
form.ui->closableTabsButton->setChecked(tabBar.tabsClosable());
QObject::connect(form.ui->closableTabsButton, &QCheckBox::toggled, [&] {
tabBar.setTabsClosable(form.ui->closableTabsButton->isChecked());
tabBar.update();
});
form.ui->expandingTabsButton->setChecked(tabBar.expanding());
QObject::connect(form.ui->expandingTabsButton, &QCheckBox::toggled, [&] {
tabBar.setExpanding(form.ui->expandingTabsButton->isChecked());
tabBar.update();
});
form.ui->displayIconButton->setChecked(!tabBar.tabIcon(0).isNull());
QObject::connect(form.ui->displayIconButton, &QCheckBox::toggled, [&] {
const auto icon = form.ui->displayIconButton->isChecked() ?
tabBar.style()->standardIcon(QStyle::SP_ComputerIcon) : QIcon();
for (int i = 0; i < tabBar.count(); i++)
tabBar.setTabIcon(i, icon);
});
form.ui->longLabelButton->setChecked(false);
QObject::connect(form.ui->longLabelButton, &QCheckBox::toggled, [&] {
const auto &label = form.ui->longLabelButton->isChecked() ? longLabel : shortLabel;
for (int i = 0; i < tabBar.count(); i++)
tabBar.setTabText(i, label.arg(i));
});
QObject::connect(form.ui->shapeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [&](int index) {
Q_UNUSED(index);
// TODO
});
if (proxyStyle->alignment == Qt::AlignLeft)
form.ui->leftAlignedButton->setChecked(true);
else if (proxyStyle->alignment == Qt::AlignRight)
form.ui->rightAlignedButton->setChecked(true);
else
form.ui->centeredButton->setChecked(true);
QObject::connect(form.ui->textAlignmentGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), [&](QAbstractButton *b) {
proxyStyle->alignment = b == form.ui->leftAlignedButton ? Qt::AlignLeft :
b == form.ui->rightAlignedButton ? Qt::AlignRight : Qt::AlignCenter;
QApplication::sendEvent(&tabBar, new QEvent(QEvent::StyleChange));
});
layout->setMargin(12);
widget.show();
return app.exec();
}