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


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

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


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

示例1: updateSize

void SidebarWidget::updateSize()
{
	QDockWidget *dockWidget = qobject_cast<QDockWidget*>(parentWidget());

	if (dockWidget)
	{
		if (m_currentWidget)
		{
			dockWidget->setMaximumWidth(QWIDGETSIZE_MAX);

			resize(SettingsManager::getValue(QLatin1String("Window/SidebarWidth")).toInt(), height());
			setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
		}
		else
		{
			dockWidget->setMaximumWidth(m_ui->buttonsLayout->contentsRect().width());

			setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
		}
	}
}
开发者ID:jernejs,项目名称:otter,代码行数:21,代码来源:SidebarWidget.cpp

示例2: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    ui->setupUi(this);
    this->resize(800,680);
    this->setWindowState(Qt::WindowMaximized);
    ImageItem *image = new ImageItem();

    //create ColorSelection
    ColorSelection *CS1 = new ColorSelection(Qt::black);
    ColorSelection *CS2 = new ColorSelection(Qt::white);
    QObject::connect(CS1,SIGNAL(changeColor(QColor)),image,SLOT(setColor1(QColor)));
    QObject::connect(image->getPipette(),SIGNAL(changeColor1(QColor)),CS1,SLOT(setColor(QColor)));
    QObject::connect(CS2,SIGNAL(changeColor(QColor)),image,SLOT(setColor2(QColor)));
    QObject::connect(image->getPipette(),SIGNAL(changeColor2(QColor)),CS2,SLOT(setColor(QColor)));
    QHBoxLayout *Hlayout = new QHBoxLayout();
    Hlayout->addStretch(5);
    Hlayout->addWidget(CS1);
    Hlayout->addWidget(CS2);
    Hlayout->addStretch(5);

    //Create slider
    QSlider *slider = new QSlider(Qt::Horizontal);
    slider->setMaximum(100);
    slider->setMinimum(1);
    slider->setValue(10);
    QObject::connect(slider,SIGNAL(valueChanged(int)),image,SLOT(setSize(int)));


    QVBoxLayout *Blayout = new QVBoxLayout();
    Blayout->addWidget(slider);
    Blayout->addLayout(Hlayout);
    QWidget *wdg = new QWidget();
    wdg->setLayout(Blayout);
    // Create Dock
    //
    //
    QDockWidget *dock = new QDockWidget(tr("Настройка"),this);
    dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
    wdg->setFixedSize(200,100);
    dock->setWidget(wdg);
    dock->setMaximumHeight(300);
    dock->setMaximumWidth(300);

    addDockWidget(Qt::RightDockWidgetArea,dock);

    QActionGroup *GP = new QActionGroup(this);
    GP->addAction(ui->actionPencil);
    GP->addAction(ui->actionEraser);
    GP->addAction(ui->actionEllipse);
    GP->addAction(ui->actionRectangle);
    GP->addAction(ui->actionLine);
    GP->addAction(ui->actionCurveLine);
    GP->addAction(ui->actionFill);
    GP->addAction(ui->actionPipette);
    GP->addAction(ui->actionSelection);
    GP->setExclusive(true);

    //create tool bar
    QToolBar *TB = new QToolBar();
    TB->setAllowedAreas(Qt::TopToolBarArea | Qt::LeftToolBarArea);
    TB->setFloatable(false);
    TB->setMovable(true);

    TB->insertAction(0,ui->actionSaveAs);
    TB->insertAction(ui->actionSaveAs,ui->actionSave);
    TB->insertAction(ui->actionSave,ui->actionOpen);
    TB->insertAction(ui->actionOpen,ui->actionCreate);
    TB->addSeparator();
    TB->insertAction(0,ui->actionSelection);
    TB->insertAction(ui->actionSelection,ui->actionPipette);
    TB->insertAction(ui->actionPipette,ui->actionFill);
    TB->insertAction(ui->actionFill,ui->actionCurveLine);
    TB->insertAction(ui->actionCurveLine,ui->actionLine);
    TB->insertAction(ui->actionLine,ui->actionRectangle);
    TB->insertAction(ui->actionRectangle,ui->actionEllipse);
    TB->insertAction(ui->actionEllipse,ui->actionEraser);
    TB->insertAction(ui->actionEraser,ui->actionPencil);




    addToolBar(Qt::TopToolBarArea, TB);
    // create action connecting
    QObject::connect(ui->actionOpen,SIGNAL(triggered(bool)),image,SLOT(open()));
    QObject::connect(ui->actionSaveAs,SIGNAL(triggered(bool)),image,SLOT(saveAs()));
    QObject::connect(ui->actionSave,SIGNAL(triggered(bool)),image,SLOT(save()));
    QObject::connect(ui->actionPencil,SIGNAL(toggled(bool)),image,SLOT(setPencil(bool)));
    QObject::connect(ui->actionEraser,SIGNAL(toggled(bool)),image,SLOT(setEraser(bool)));
    QObject::connect(ui->actionEllipse,SIGNAL(toggled(bool)),image,SLOT(setEllipse(bool)));
    QObject::connect(ui->actionRectangle,SIGNAL(toggled(bool)),image,SLOT(setRectangle(bool)));
    QObject::connect(ui->actionLine,SIGNAL(toggled(bool)),image,SLOT(setLine(bool)));
    QObject::connect(ui->actionCurveLine,SIGNAL(toggled(bool)),image,SLOT(setCurveLine(bool)));
    QObject::connect(ui->actionFill,SIGNAL(toggled(bool)),image,SLOT(setFill(bool)));
    QObject::connect(ui->actionPipette,SIGNAL(toggled(bool)),image,SLOT(setPipette(bool)));
    QObject::connect(ui->actionSelection,SIGNAL(toggled(bool)),image,SLOT(setSelection(bool)));
    //undo and redo
//.........这里部分代码省略.........
开发者ID:Dearg7,项目名称:graphics-editor,代码行数:101,代码来源:mainwindow.cpp


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