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


C++ QToolButton::setMaximumWidth方法代码示例

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


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

示例1: CreateWindowContents

// //! [CustomViewerWorkbenchWindowAdvisorPreWindowOpen]
// //! [WorkbenchWindowAdvisorCreateWindowContentsHead]
void CustomViewerWorkbenchWindowAdvisor::CreateWindowContents(berry::Shell::Pointer shell)
{
  //the all containing main window
  QMainWindow* mainWindow = static_cast<QMainWindow*>(shell->GetControl());
// //! [WorkbenchWindowAdvisorCreateWindowContentsHead]
  mainWindow->setVisible(true);

  //the widgets
  QWidget* CentralWidget = new QWidget(mainWindow);
  CentralWidget->setObjectName("CentralWidget");
  CentralWidget->setVisible(true);

  QtPerspectiveSwitcherTabBar* PerspectivesTabBar = new QtPerspectiveSwitcherTabBar(this->GetWindowConfigurer()->GetWindow());
  PerspectivesTabBar->setObjectName("PerspectivesTabBar");
  PerspectivesTabBar->addTab("Image Viewer");
  PerspectivesTabBar->addTab("DICOM-Manager");
  PerspectivesTabBar->setVisible(true);
  PerspectivesTabBar->setDrawBase(false);

  QPushButton* StyleUpdateButton = new QPushButton("Update Style", mainWindow);
  StyleUpdateButton->setMaximumWidth(100);
  StyleUpdateButton->setObjectName("StyleUpdateButton");
  QObject::connect(StyleUpdateButton, SIGNAL( clicked() ), this, SLOT( UpdateStyle() ));

  QToolButton* OpenFileButton = new QToolButton(mainWindow);
  OpenFileButton->setMaximumWidth(100);
  OpenFileButton->setObjectName("FileOpenButton");
  OpenFileButton->setText("Open File");
  QObject::connect(OpenFileButton, SIGNAL( clicked() ), this, SLOT( OpenFile() ));

  QWidget* PageComposite = new QWidget(CentralWidget);
  PageComposite->setObjectName("PageComposite");
  PageComposite->setVisible(true);

  //the layouts
  QVBoxLayout* CentralWidgetLayout = new QVBoxLayout(CentralWidget);
  CentralWidgetLayout->contentsMargins();
  CentralWidgetLayout->setContentsMargins(9,9,9,9);
  CentralWidgetLayout->setSpacing(0);
  CentralWidgetLayout->setObjectName("CentralWidgetLayout");

  QHBoxLayout* PerspectivesLayer = new QHBoxLayout(mainWindow);
  PerspectivesLayer->setObjectName("PerspectivesLayer");

  QHBoxLayout* PageCompositeLayout = new QHBoxLayout(PageComposite);
  PageCompositeLayout->setContentsMargins(0,0,0,0);
  PageCompositeLayout->setSpacing(0);
  PageComposite->setLayout(PageCompositeLayout);
// //! [WorkbenchWindowAdvisorCreateWindowContents]
  //all glued together
  mainWindow->setCentralWidget(CentralWidget);
  CentralWidgetLayout->addLayout(PerspectivesLayer);
  CentralWidgetLayout->addWidget(PageComposite);
  CentralWidget->setLayout(CentralWidgetLayout);
  PerspectivesLayer->addWidget(PerspectivesTabBar);
  PerspectivesLayer->addSpacing(300);
  PerspectivesLayer->addWidget(OpenFileButton);

  //for style customization convenience
  /*PerspectivesLayer->addSpacing(10);
  PerspectivesLayer->addWidget(StyleUpdateButton);*/

  //for correct initial layout, see also bug#1654
  CentralWidgetLayout->activate();
  CentralWidgetLayout->update();

  this->GetWindowConfigurer()->CreatePageComposite(PageComposite);
// //! [WorkbenchWindowAdvisorCreateWindowContents]
}
开发者ID:0r,项目名称:MITK,代码行数:71,代码来源:CustomViewerWorkbenchWindowAdvisor.cpp

示例2: QWidget


//.........这里部分代码省略.........
        // horizontal line
        QFrame* line = new QFrame();
        line->setFrameShape(QFrame::HLine);
        line->setFrameShadow(QFrame::Raised);
        layout->addWidget(line);
    }

    // everything else is added to the following widget which just has a different background color
    QVBoxLayout* bodyLayout = new QVBoxLayout;
    {
        QWidget* body = new QWidget();
        body->setLayout(bodyLayout);
        layout->addWidget(body);
        body->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    }

    // document list actions
    {
        QHBoxLayout* actionsLayout = new QHBoxLayout;

        QLabel* label = new QLabel(i18n("Documents:"));
        label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
        actionsLayout->addWidget(label);

        actionsLayout->addStretch();

        m_mergeButton = new QPushButton;
        m_mergeButton->setIcon(KIcon("list-add"));
        m_mergeButton->setText(i18n("Add All"));
        m_mergeButton->setToolTip(i18n("Add all documents that are part of this working set to the currently active working set."));
        m_mergeButton->setFlat(true);
        connect(m_mergeButton, SIGNAL(clicked(bool)), m_setButton, SLOT(mergeSet()));
        actionsLayout->addWidget(m_mergeButton);

        m_subtractButton = new QPushButton;
        m_subtractButton->setIcon(KIcon("list-remove"));
        m_subtractButton->setText(i18n("Subtract All"));
        m_subtractButton->setToolTip(i18n("Remove all documents that are part of this working set from the currently active working set."));
        m_subtractButton->setFlat(true);
        connect(m_subtractButton, SIGNAL(clicked(bool)), m_setButton, SLOT(subtractSet()));
        actionsLayout->addWidget(m_subtractButton);
        bodyLayout->addLayout(actionsLayout);
    }

    QSet<QString> hadFiles;

    QVBoxLayout* filesLayout = new QVBoxLayout;
    filesLayout->setMargin(0);

    foreach(const QString& file, m_set->fileList()) {

        if(hadFiles.contains(file))
            continue;

        hadFiles.insert(file);

        FileWidget* widget = new FileWidget;
        widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);

        QHBoxLayout* fileLayout = new QHBoxLayout(widget);

        QToolButton* plusButton = new QToolButton;
        plusButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum);
        fileLayout->addWidget(plusButton);

        WorkingSetFileLabel* fileLabel = new WorkingSetFileLabel;
        fileLabel->setTextFormat(Qt::RichText);
        // We add spaces behind and after, to make it look nicer
        fileLabel->setText("&nbsp;" + Core::self()->projectController()->prettyFileName(KUrl(file)) + "&nbsp;");
        fileLabel->setToolTip(i18nc("@info:tooltip", "Click to open and activate this document."));
        fileLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
        fileLayout->addWidget(fileLabel);
        fileLayout->setMargin(0);

        plusButton->setMaximumHeight(fileLabel->sizeHint().height() + 4);
        plusButton->setMaximumWidth(plusButton->maximumHeight());

        plusButton->setObjectName(file);
        fileLabel->setObjectName(file);
        fileLabel->setCursor(QCursor(Qt::PointingHandCursor));

        widget->m_button = plusButton;
        widget->m_label = fileLabel;

        filesLayout->addWidget(widget);
        m_fileWidgets.insert(file, widget);
        m_orderedFileWidgets.push_back(widget);

        connect(plusButton, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool)));
        connect(fileLabel, SIGNAL(clicked()), this, SLOT(labelClicked()));
    }

    bodyLayout->addLayout(filesLayout);

    updateFileButtons();
    connect(set, SIGNAL(setChangedSignificantly()), SLOT(updateFileButtons()));
    connect(mainwindow->area(), SIGNAL(changedWorkingSet(Sublime::Area*,QString,QString)), SLOT(updateFileButtons()), Qt::QueuedConnection);

    QMetaObject::invokeMethod(this, "updateFileButtons");
}
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:101,代码来源:workingsettooltipwidget.cpp

示例3: exec

int DriverColorsDialog::exec()
{
    SeasonData &sd = SeasonData::getInstance();
    colors = ColorsManager::getInstance().getDriverColors();
    int i = 0;
    for (; i < sd.getTeams().size(); ++i)
    {
        QList<LTDriver> drivers = sd.getMainDrivers(sd.getTeams()[i]);
        if (drivers.size() != 2)
            continue;

        if ((ui->verticalLayout->count()-2) <= i)
        {
            QHBoxLayout *layout = new QHBoxLayout();
            QLabel *label = new QLabel(this);                        

            label->setText(QString("%1 %2").arg(drivers[0].no).arg(drivers[0].name));
            label->updateGeometry();
            QToolButton *button = new QToolButton(this);
            button->setMaximumHeight(16);
            button->setMaximumWidth(16);
            setButtonColor(button, /*sd.getCarColor(sd.getTeams()[i].driver1No)*/colors[i*2]);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onColorButtonClicked()));

            button = new QToolButton(this);
            button->setText("Reset");
            button->setMaximumHeight(20);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onResetButtonClicked()));

            layout->addWidget(label);
            //colors.append(sd.getCarColor(sd.getTeams()[i].driver1No));

//            layout = new QHBoxLayout(this);
            label = new QLabel(this);
            label->setText(QString("%1 %2").arg(drivers[1].no).arg(drivers[1].name));
            label->updateGeometry();
            button = new QToolButton(this);
            button->setMaximumHeight(16);
            button->setMaximumWidth(16);
            setButtonColor(button, /*sd.getCarColor(sd.getTeams()[i].driver2No)*/colors[i*2+1]);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onColorButtonClicked()));

            button = new QToolButton(this);
            button->setText("Reset");
            button->setMaximumHeight(20);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onResetButtonClicked()));

            layout->addWidget(label);
            //colors.append(sd.getCarColor(sd.getTeams()[i].driver2No));

            ui->verticalLayout->insertLayout(ui->verticalLayout->count() - 2, layout);
        }
        else
        {
            QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
            QLabel *label = static_cast<QLabel*>(layout->itemAt(2)->widget());
            QToolButton *button = static_cast<QToolButton*>(layout->itemAt(0)->widget());

            label->setText(QString("%1 %2").arg(drivers[0].no).arg(drivers[0].name));
            setButtonColor(button, ColorsManager::getInstance().getCarColor(drivers[0].no));

            label->setVisible(true);
            button->setVisible(true);

            button = static_cast<QToolButton*>(layout->itemAt(1)->widget());
            button->setVisible(true);

            label = static_cast<QLabel*>(layout->itemAt(5)->widget());
            button = static_cast<QToolButton*>(layout->itemAt(3)->widget());

            label->setText(QString("%1 %2").arg(drivers[1].no).arg(drivers[1].name));
            setButtonColor(button, ColorsManager::getInstance().getCarColor(drivers[1].no));

            label->setVisible(true);
            button->setVisible(true);

            button = static_cast<QToolButton*>(layout->itemAt(4)->widget());
            button->setVisible(true);
        }
    }
    for (; i < ui->verticalLayout->count()-2; ++i)
    {
        QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
        QLabel *label = static_cast<QLabel*>(layout->itemAt(2)->widget());
        QToolButton *button = static_cast<QToolButton*>(layout->itemAt(0)->widget());

        label->setVisible(false);
        button->setVisible(false);

        button = static_cast<QToolButton*>(layout->itemAt(1)->widget());
        button->setVisible(false);

        label = static_cast<QLabel*>(layout->itemAt(5)->widget());
        button = static_cast<QToolButton*>(layout->itemAt(3)->widget());

        label->setVisible(false);
//.........这里部分代码省略.........
开发者ID:HxCory,项目名称:f1lt,代码行数:101,代码来源:drivercolorsdialog.cpp

示例4: SetupUI


//.........这里部分代码省略.........
		QObject::connect(action, &QAction::triggered, this, [&]() {
			appWindows["CSoundOptions"]->Toggle();
		});
	}
	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("Help");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		QAction *action = new QAction(MainWindow);
		action->setText("About");
		action->setIcon(*QtConfig::GetIcon("chat.png"));
		menu->addAction(action);

		appWindows["About"] = new AboutWindow();

		QObject::connect(action, &QAction::triggered, this, [&]() {
			appWindows["About"]->Toggle();
		});
	}

	// ************************************************************************
	// Toolbar

	QToolBar *toolbar = new QToolBar();
	toolbar->setWindowTitle("Toolbar");

	// Play Audio
	{
		QToolButton *button = new QToolButton();
		button->setText("Play");
		button->setMaximumWidth(80);
		button->setIcon(*QtConfig::GetIcon("play.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			CSoundEditor::GetScene()->Play();
		});
		toolbar->addWidget(button);
	}

	// Stop Audio
	{
		QToolButton *button = new QToolButton();
		button->setText("Stop");
		button->setMaximumWidth(80);
		button->setIcon(*QtConfig::GetIcon("volume_disabled.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			CSoundEditor::GetScene()->Stop();
		});
		toolbar->addWidget(button);
	}

	// Save Scene
	{
		QToolButton *button = new QToolButton();
		button->setText("Save Scene");
		button->setIcon(*QtConfig::GetIcon("download.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			auto result = CSoundEditor::GetScene()->SaveScene();
			if (!result) {
				auto picker = GUI::Get<FilePicker>(QT_INSTACE::FILE_PICKER);
				if (picker) {
开发者ID:ReDEnergy,项目名称:3DSound-Prototypying,代码行数:67,代码来源:EditorMainWindow.cpp


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