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


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

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


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

示例1: MakeTabBar

void FancyTabWidget::MakeTabBar(QTabBar::Shape shape, bool text, bool icons,
                                bool fancy) {
  QTabBar* bar = new QTabBar(this);
  bar->setShape(shape);
  bar->setDocumentMode(true);
  bar->setUsesScrollButtons(true);
  bar->setElideMode(Qt::ElideRight);

  if (shape == QTabBar::RoundedWest) {
    bar->setIconSize(QSize(22, 22));
  }

  if (fancy) {
    bar->setStyle(proxy_style_.get());
  }

  if (shape == QTabBar::RoundedNorth)
    top_layout_->insertWidget(0, bar);
  else
    side_layout_->insertWidget(0, bar);

  foreach (const Item& item, items_) {
    if (item.type_ != Item::Type_Tab)
      continue;

    QString label = item.tab_label_;
    if (shape == QTabBar::RoundedWest) {
      label = QFontMetrics(font()).elidedText(label, Qt::ElideMiddle, 100);
    }

    int tab_id = -1;
    if (icons && text)
      tab_id = bar->addTab(item.tab_icon_, label);
    else if (icons)
      tab_id = bar->addTab(item.tab_icon_, QString());
    else if (text)
      tab_id = bar->addTab(label);

    // Adds tooltips only in Tabs mode or IconOnlyTabs mode
    // TODO in tab mode, show only if not elided, complicated since this doesn't inherit from QTabWidget
    if (shape == QTabBar::RoundedNorth && ((!text && icons) || (text && !icons)))
      bar->setTabToolTip(tab_id, item.tab_label_);
  }

  bar->setCurrentIndex(stack_->currentIndex());
  connect(bar, SIGNAL(currentChanged(int)), SLOT(ShowWidget(int)));
  tab_bar_ = bar;
}
开发者ID:ximion,项目名称:Clementine-LibDanceTag,代码行数:48,代码来源:fancytabwidget.cpp

示例2: MakeTabBar

void FancyTabWidget::MakeTabBar(QTabBar::Shape shape, bool text, bool icons,
                                bool fancy) {
  QTabBar* bar = new QTabBar(this);
  bar->setShape(shape);
  bar->setDocumentMode(true);
  bar->setUsesScrollButtons(true);

  if (shape == QTabBar::RoundedWest) {
    bar->setIconSize(QSize(22, 22));
  }

  if (fancy) {
    bar->setStyle(proxy_style_.data());
  }

  if (shape == QTabBar::RoundedNorth)
    top_layout_->insertWidget(0, bar);
  else
    side_layout_->insertWidget(0, bar);

  foreach (const Item& item, items_) {
    if (item.type_ != Item::Type_Tab)
      continue;

    QString label = item.tab_label_;
    if (shape == QTabBar::RoundedWest) {
      label = QFontMetrics(font()).elidedText(label, Qt::ElideMiddle, 100);
    }

    int tab_id = -1;
    if (icons && text)
      tab_id = bar->addTab(item.tab_icon_, label);
    else if (icons)
      tab_id = bar->addTab(item.tab_icon_, QString());
    else if (text)
      tab_id = bar->addTab(label);

    bar->setTabToolTip(tab_id, item.tab_label_);
  }

  bar->setCurrentIndex(stack_->currentIndex());
  connect(bar, SIGNAL(currentChanged(int)), SLOT(ShowWidget(int)));
  tab_bar_ = bar;
}
开发者ID:sriram1103,项目名称:knowthelist,代码行数:44,代码来源:fancytabwidget.cpp

示例3: GcWindow

HomeWindow::HomeWindow(MainWindow *mainWindow, QString name, QString /* windowtitle */) :
    GcWindow(mainWindow), mainWindow(mainWindow), name(name), active(false),
    clicked(NULL), dropPending(false), chartCursor(-2), loaded(false)
{
    setInstanceName("Home Window");

    // setup control area
    QWidget *cw = new QWidget(this);
    cw->setContentsMargins(0,0,0,0);

    QVBoxLayout *cl = new QVBoxLayout(cw);
    cl->setSpacing(0);
    cl->setContentsMargins(0,0,0,0);

    QLabel *titleLabel = new QLabel("Title", this);
    QHBoxLayout *hl = new QHBoxLayout;
    hl->setSpacing(5);
    hl->setContentsMargins(0,0,0,0);

    titleEdit = new QLineEdit(this);
    titleEdit->setEnabled(false);
    controlStack = new QStackedWidget(this);
    controlStack->setContentsMargins(0,0,0,0);
    hl->addWidget(titleLabel);
    hl->addWidget(titleEdit);
    cl->addLayout(hl);
    cl->addSpacing(15);
    cl->addWidget(controlStack);
    setControls(cw);

    setProperty("isManager", true);
    setAcceptDrops(true);

    QVBoxLayout *layout = new QVBoxLayout(this);

    QFont bigandbold;
    bigandbold.setPointSize(bigandbold.pointSize() + 2);
    bigandbold.setWeight(QFont::Bold);

    QHBoxLayout *titleBar = new QHBoxLayout;

    QLabel *space = new QLabel("", this);
    space->setFixedHeight(20);
    titleBar->addWidget(space);

    style = new QStackedWidget(this);
    style->setAutoFillBackground(false);
    layout->setSpacing(0);
    layout->setContentsMargins(0,0,0,0);
    layout->addWidget(style);

    QPalette palette;
    palette.setBrush(backgroundRole(), QColor("#B3B4B6"));
    setAutoFillBackground(false);

    // each style has its own container widget
    QWidget *tabArea = new QWidget(this);
    tabArea->setContentsMargins(20,20,20,20);
    QVBoxLayout *tabLayout = new QVBoxLayout(tabArea);
    tabLayout->setContentsMargins(0,0,0,0);
    tabLayout->setSpacing(0);
    tabbed = new QTabWidget(this);
#ifdef Q_OS_MAC
    tabbed->setAttribute(Qt::WA_MacShowFocusRect, 0);
#endif
    tabbed->setContentsMargins(0,0,0,0);
    tabbed->setTabsClosable(false);
    tabbed->setPalette(palette);
    tabbed->setDocumentMode(false);
    tabbed->setMovable(true);
    tabbed->setElideMode(Qt::ElideNone);
    tabbed->setUsesScrollButtons(true);

    QTabBar *tb = tabbed->findChild<QTabBar*>(QLatin1String("qt_tabwidget_tabbar"));
    tb->setShape(QTabBar::RoundedSouth);
    tb->setDrawBase(false);
    tabbed->setStyleSheet("QTabWidget::tab-bar { alignment: center; }"
                          "QTabWidget::pane { top: 20px; }");

    tabLayout->addWidget(tabbed);
    style->addWidget(tabArea);

    // tiled
    tileWidget = new QWidget(this);
    tileWidget->setAutoFillBackground(false);
    tileWidget->setPalette(palette);
    tileWidget->setContentsMargins(0,0,0,0);

    tileGrid = new QGridLayout(tileWidget);
    tileGrid->setSpacing(0);

    tileArea = new QScrollArea(this);
    tileArea->setAutoFillBackground(false);
    tileArea->setPalette(palette);
    tileArea->setWidgetResizable(true);
    tileArea->setWidget(tileWidget);
    tileArea->setFrameStyle(QFrame::NoFrame);
    tileArea->setContentsMargins(0,0,0,0);
    style->addWidget(tileArea);

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: if


//.........这里部分代码省略.........
            MessagesPlainTextEditTab* new_tab = new MessagesPlainTextEditTab(0,toolbar_area);
            d->message_displays[WidgetLoggerEngine::IssuesPlainTextEdit] = new_tab;
            QDockWidget* new_dock = new QDockWidget("Issues");

            // We don't want users to be able to close the individual log
            // dock widgets since there is no way to get them back then
            // until the application is restarted.
            QDockWidget::DockWidgetFeatures features = new_dock->features();
            features &= ~QDockWidget::DockWidgetClosable;
            new_dock->setFeatures(features);

            d->message_display_docks[WidgetLoggerEngine::IssuesPlainTextEdit] = new_dock;
            connect(new_dock,SIGNAL(visibilityChanged(bool)),SLOT(handle_dockVisibilityChanged(bool)));
            new_dock->setWidget(new_tab);
            addDockWidget(Qt::BottomDockWidgetArea,new_dock);

            if (d->message_displays_flag & WidgetLoggerEngine::AllMessagesPlainTextEdit)
                issues_index = 1;
            else
                issues_index = 0;
        }

        if (d->message_displays_flag & WidgetLoggerEngine::WarningsPlainTextEdit) {
            MessagesPlainTextEditTab* new_tab = new MessagesPlainTextEditTab(0,toolbar_area);
            d->message_displays[WidgetLoggerEngine::WarningsPlainTextEdit] = new_tab;
            QDockWidget* new_dock = new QDockWidget("Warnings");

            // We don't want users to be able to close the individual log
            // dock widgets since there is no way to get them back then
            // until the application is restarted.
            QDockWidget::DockWidgetFeatures features = new_dock->features();
            features &= ~QDockWidget::DockWidgetClosable;
            new_dock->setFeatures(features);

            d->message_display_docks[WidgetLoggerEngine::WarningsPlainTextEdit] = new_dock;
            connect(new_dock,SIGNAL(visibilityChanged(bool)),SLOT(handle_dockVisibilityChanged(bool)));
            new_dock->setWidget(new_tab);
            addDockWidget(Qt::BottomDockWidgetArea,new_dock);

            if (d->message_displays_flag & WidgetLoggerEngine::AllMessagesPlainTextEdit && d->message_displays_flag & WidgetLoggerEngine::IssuesPlainTextEdit)
                warning_index = 2;
            else if (d->message_displays_flag & WidgetLoggerEngine::AllMessagesPlainTextEdit)
                warning_index = 1;
            else
                warning_index = 0;
        }

        if (d->message_displays_flag & WidgetLoggerEngine::ErrorsPlainTextEdit) {
            MessagesPlainTextEditTab* new_tab = new MessagesPlainTextEditTab(0,toolbar_area);
            d->message_displays[WidgetLoggerEngine::ErrorsPlainTextEdit] = new_tab;
            QDockWidget* new_dock = new QDockWidget("Errors");

            // We don't want users to be able to close the individual log
            // dock widgets since there is no way to get them back then
            // until the application is restarted.
            QDockWidget::DockWidgetFeatures features = new_dock->features();
            features &= ~QDockWidget::DockWidgetClosable;
            new_dock->setFeatures(features);

            d->message_display_docks[WidgetLoggerEngine::ErrorsPlainTextEdit] = new_dock;
            connect(new_dock,SIGNAL(visibilityChanged(bool)),SLOT(handle_dockVisibilityChanged(bool)));
            new_dock->setWidget(new_tab);
            addDockWidget(Qt::BottomDockWidgetArea,new_dock);

            if (d->message_displays_flag & WidgetLoggerEngine::AllMessagesPlainTextEdit && d->message_displays_flag & WidgetLoggerEngine::IssuesPlainTextEdit && d->message_displays_flag & WidgetLoggerEngine::WarningsPlainTextEdit)
                error_index = 3;
            else if (d->message_displays_flag & WidgetLoggerEngine::AllMessagesPlainTextEdit && d->message_displays_flag & WidgetLoggerEngine::WarningsPlainTextEdit)
                error_index = 2;
            else if (d->message_displays_flag & WidgetLoggerEngine::AllMessagesPlainTextEdit && d->message_displays_flag & WidgetLoggerEngine::IssuesPlainTextEdit)
                error_index = 2;
            else if (d->message_displays_flag & WidgetLoggerEngine::AllMessagesPlainTextEdit)
                error_index = 1;
            else if (d->message_displays_flag & WidgetLoggerEngine::WarningsPlainTextEdit)
                error_index = 1;
            else if (d->message_displays_flag & WidgetLoggerEngine::IssuesPlainTextEdit)
                error_index = 1;
            else
                error_index = 0;
        }

        for (int i = 1; i < d->message_display_docks.count(); ++i)
            tabifyDockWidget(d->message_display_docks.values().at(i-1),d->message_display_docks.values().at(i));

        QList<QTabBar *> tabList = findChildren<QTabBar *>();
        if (!tabList.isEmpty()) {
            QTabBar *tabBar = tabList.at(0);
            tabBar->setCurrentIndex(0);
            tabBar->setShape(QTabBar::RoundedSouth);

            if (info_index != -1)
                tabBar->setTabIcon(info_index,QIcon(qti_icon_INFO_12x12));
            if (issues_index != -1)
                tabBar->setTabIcon(issues_index,QIcon(qti_icon_WARNING_12x12));
            if (warning_index != -1)
                tabBar->setTabIcon(warning_index,QIcon(qti_icon_WARNING_12x12));
            if (error_index != -1)
                tabBar->setTabIcon(error_index,QIcon(qti_icon_ERROR_12x12));
        }
    }
}
开发者ID:CJCombrink,项目名称:Qtilities,代码行数:101,代码来源:WidgetLoggerEngineFrontend.cpp

示例5: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    auto *proxyStyle = new TabBarProxyStyle;
    app.setStyle(proxyStyle);

    QWidget widget;
    QStackedWidget stackedWidget;
    QTabBar tabBar;
    tabBar.setDocumentMode(true);
    tabBar.setTabsClosable(true);
    tabBar.setMovable(true);
    tabBar.setExpanding(false);

    // top
    tabBar.setShape(QTabBar::RoundedNorth);
    // bottom
//    tabBar.setShape(QTabBar::RoundedSouth);
    // left
//    tabBar.setShape(QTabBar::RoundedWest);
    // right
//    tabBar.setShape(QTabBar::RoundedEast);

    const auto shortLabel = QStringLiteral("Tab %1");
    const auto longLabel = QStringLiteral("An Extremely Long Tab Label %1");

    QMap<int, QWidget*> tabs;
    for (int i = 0; i < TabCount; i++) {
        QString tabNumberString = QString::number(i);
        QLabel *label = new QLabel(QStringLiteral("Tab %1 content").arg(tabNumberString));
        tabs[i] = label;
        label->setAlignment(Qt::AlignCenter);
        stackedWidget.addWidget(label);
        tabBar.addTab(shortLabel.arg(tabNumberString));
    }

    QObject::connect(&tabBar, &QTabBar::tabMoved, [&tabs](int from, int to) {
        QWidget *thisWidget = tabs[from];
        QWidget *thatWidget = tabs[to];
        tabs[from] = thatWidget;
        tabs[to] = thisWidget;
    });

    QObject::connect(&tabBar, &QTabBar::currentChanged, [&stackedWidget, &tabs](int index) {
        if (index >= 0)
            stackedWidget.setCurrentWidget(tabs[index]);
    });

    QObject::connect(&tabBar, &QTabBar::tabCloseRequested, [&stackedWidget, &tabBar, &tabs](int index) {
        QWidget *widget = tabs[index];
        tabBar.removeTab(index);
        for (int i = index + 1; i < TabCount; i++)
            tabs[i-1] = tabs[i];
        int currentIndex = tabBar.currentIndex();
        if (currentIndex >= 0)
            stackedWidget.setCurrentWidget(tabs[currentIndex]);
        delete widget;
    });

    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));
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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