当前位置: 首页>>代码示例>>C++>>正文


C++ QTabBar::style方法代码示例

本文整理汇总了C++中QTabBar::style方法的典型用法代码示例。如果您正苦于以下问题:C++ QTabBar::style方法的具体用法?C++ QTabBar::style怎么用?C++ QTabBar::style使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTabBar的用法示例。


在下文中一共展示了QTabBar::style方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: closeButton

void tst_QTabBar::closeButton()
{
    QTabBar tabbar;
    QCOMPARE(tabbar.tabsClosable(), false);
    tabbar.setTabsClosable(true);
    QCOMPARE(tabbar.tabsClosable(), true);
    tabbar.addTab("foo");

    QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)tabbar.style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, &tabbar);
    QTabBar::ButtonPosition otherSide = (closeSide == QTabBar::LeftSide ? QTabBar::RightSide : QTabBar::LeftSide);
    QVERIFY(tabbar.tabButton(0, otherSide) == 0);
    QVERIFY(tabbar.tabButton(0, closeSide) != 0);

    QAbstractButton *button = static_cast<QAbstractButton*>(tabbar.tabButton(0, closeSide));
    QVERIFY(button);
    QSignalSpy spy(&tabbar, SIGNAL(tabCloseRequested(int)));
    button->click();
    QCOMPARE(tabbar.count(), 1);
    QCOMPARE(spy.count(), 1);
}
开发者ID:maxxant,项目名称:qt,代码行数:20,代码来源:tst_qtabbar.cpp

示例2: QVBoxLayout


//.........这里部分代码省略.........
	//
	m_pFinder = new CFinder();
	m_pSubLayout->addWidget(m_pFinder);
	QObject::connect(m_pFinder, SIGNAL(SetFilter(const QRegExp&)), m_pFileList, SLOT(SetFilter(const QRegExp&)));

    QAction* pFinder = new QAction(tr("&Find ..."), this);
	pFinder->setShortcut(QKeySequence::Find);
	pFinder->setShortcutContext(Qt::WidgetWithChildrenShortcut);
	this->addAction(pFinder);
    QObject::connect(pFinder, SIGNAL(triggered()), m_pFinder, SLOT(Open()));
	//

	m_pSubWidget->setLayout(m_pSubLayout);

	m_pSplitter->addWidget(m_pSubWidget);

	m_pFileTabs = new QTabWidget();

	m_pSummary = new CFileSummary(Mode);
	m_pFileTabs->addTab(m_pSummary, tr("Summary"));

	m_pDetails = new CDetailsView(Mode);
	m_pFileTabs->addTab(m_pDetails, tr("Details"));

	//QMultiMap<int, SField> Settings;
	//SetupFile(Settings);
	//m_pSettings = new CFileSettingsView(Settings);
	//m_pFileTabs->addTab(m_pSettings, tr("Settings"));

	if(theGUI->Cfg()->GetInt("Gui/AdvancedControls"))
	{
		m_pTransfers = new CTransfersView(CTransfersView::eTransfers);
		m_pFileTabs->addTab(m_pTransfers, tr("Transfers"));
		connect(m_pTransfers, SIGNAL(OpenTransfer(uint64, uint64)), this, SLOT(OpenLog(uint64, uint64)));
	}
	else
		m_pTransfers = NULL;

	m_pSubFiles = new CFileListView(CFileListView::eSubFiles);
	m_pFileTabs->addTab(m_pSubFiles, tr("Sub Files"));

	m_pHosting = new CHostingView();
	m_pFileTabs->addTab(m_pHosting, tr("Hosting"));

	if(theGUI->Cfg()->GetInt("Gui/AdvancedControls"))
	{
		m_pTracker = new CTrackerView();
		m_pFileTabs->addTab(m_pTracker, tr("Tracker"));
	}
	else
		m_pTracker = NULL;
	
	m_pRating = new CRatingView();
	connect(m_pRating, SIGNAL(FindRating()), m_pFileList, SLOT(OnFindRating()));
	connect(m_pRating, SIGNAL(ClearRating()), m_pFileList, SLOT(OnClearRating()));
	m_pFileTabs->addTab(m_pRating, tr("Rating"));

	if(theGUI->Cfg()->GetInt("Gui/AdvancedControls") == 1)
	{
		m_pProperties = new CPropertiesView(true);
		m_pFileTabs->addTab(m_pProperties, tr("Properties"));
	}
	else
		m_pProperties = NULL;

	if(theGUI->Cfg()->GetBool("Gui/ShowLog"))
	{
		m_pLogView = new CLogView();
		m_pFileTabs->addTab(m_pLogView, tr("Log"));
	}
	else
		m_pLogView = NULL;

	// Make all additionaly added tabs closable - client log tab
	m_pFileTabs->setTabsClosable(true);
	QTabBar* pTabBar = m_pFileTabs->tabBar();
	m_TabOffset = m_pFileTabs->count();
	for(int i=0; i < m_TabOffset; i++)
		pTabBar->setTabButton(i,static_cast<QTabBar::ButtonPosition>(pTabBar->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition,  0, pTabBar)),0);

	connect(pTabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(CloseLog(int)));

	m_pSplitter->addWidget(m_pFileTabs);

	m_pMainLayout->addWidget(m_pSplitter);
	m_pProgress = new QProgressBar();
	m_pProgress->setVisible(false);
	m_pProgress->setMinimum(0);
	m_pProgress->setMaximum(100);
	m_pMainLayout->addWidget(m_pProgress);

	setLayout(m_pMainLayout);

	connect(m_pFileTabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab(int)));

	m_pSplitter->restoreState(theGUI->Cfg()->GetBlob("Gui/Widget_" + m_Ops + "_Spliter"));
	m_pFileTabs->setCurrentIndex(theGUI->Cfg()->GetSetting("Gui/Widget_" + m_Ops + "_Detail").toInt());

	m_TimerId = startTimer(1000);
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:101,代码来源:FileListWidget.cpp

示例3: 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();
}
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的QTabBar::style方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。