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


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

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


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

示例1: dockLocationChanged

void tst_QDockWidget::dockLocationChanged()
{
    qRegisterMetaType<Qt::DockWidgetArea>("Qt::DockWidgetArea");

    QMainWindow mw;
    QDockWidget dw;
    dw.setObjectName("dock1");
    QSignalSpy spy(&dw, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)));

    mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
                Qt::LeftDockWidgetArea);
    spy.clear();

    mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
                Qt::LeftDockWidgetArea);
    spy.clear();

    mw.addDockWidget(Qt::RightDockWidgetArea, &dw);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
                Qt::RightDockWidgetArea);
    spy.clear();

    mw.removeDockWidget(&dw);
    QCOMPARE(spy.count(), 0);

    QDockWidget dw2;
    dw2.setObjectName("dock2");
    mw.addDockWidget(Qt::TopDockWidgetArea, &dw2);
    mw.tabifyDockWidget(&dw2, &dw);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
                Qt::TopDockWidgetArea);
    spy.clear();

    mw.splitDockWidget(&dw2, &dw, Qt::Horizontal);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
                Qt::TopDockWidgetArea);
    spy.clear();

    dw.setFloating(true);
    QTest::qWait(100);
    dw.setFloating(false);
    QTest::qWait(100);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
             Qt::TopDockWidgetArea);
    spy.clear();

    QByteArray ba = mw.saveState();
    mw.restoreState(ba);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
             Qt::TopDockWidgetArea);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:60,代码来源:tst_qdockwidget.cpp

示例2: MakeGLView

void ExecutingPietLibraries::MakeGLView (std::vector<PietTree> & pt){
    if(pt.size() == 0 )return;
    if(pt[0].isLeaf()) return;
    pt = pt[0].Nodes();

    if(pt.size() < 3) return;
    int w = pt[0].Val();
    int h = pt[1].Val();
    QString title = pt[2].toString();
    for(int i:range(3)) pt.pop_back();
    GLGameWidget* glgw = GLGameWidget::MakeUniqueGLWidget(nullptr);
    if(glgw == nullptr) return ;
    glgw->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    glgw->setSize(w,h);

    QDockWidget* dw = new QDockWidget(nullptr);
    dw->setFloating(true);
    dw->setAllowedAreas(Qt::NoDockWidgetArea);
    dw->connect(dw,&QDockWidget::dockLocationChanged,[=](){ dw->setFloating(true);});
    dw->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    dw->setWidget(glgw);
    dw->setAttribute(Qt::WA_DeleteOnClose);
    dw->setWindowTitle(title);
    dw->show();
}
开发者ID:Muratam,项目名称:UltraPiet,代码行数:25,代码来源:executingpietlibraries.cpp

示例3: sizeHint

void tst_QDockWidget::task169808_setFloating()
{
    //we try to test if the sizeHint of the dock widget widget is taken into account

    class MyWidget : public QWidget
    {
    public:
        QSize sizeHint() const
        {
            const QRect& deskRect = qApp->desktop()->availableGeometry();
            return QSize(qMin(300, deskRect.width() / 2), qMin(300, deskRect.height() / 2));
        }

        QSize minimumSizeHint() const
        {
            return QSize(20,20);
        }

        void paintEvent(QPaintEvent *)
        {
            QPainter p(this);
            p.fillRect(rect(), Qt::red);
        }
    };
    QMainWindow mw;
    mw.setCentralWidget(new MyWidget);
    QDockWidget *dw = new QDockWidget("my dock");
    dw->setWidget(new MyWidget);
    mw.addDockWidget(Qt::LeftDockWidgetArea, dw);
    dw->setFloating(true);
    mw.show();
    QVERIFY(QTest::qWaitForWindowExposed(&mw));

    QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint());

    //and now we try to test if the contents margin is taken into account
    dw->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    dw->setFloating(false);
    QVERIFY(QTest::qWaitForWindowExposed(&mw));
    qApp->processEvents(); //leave time processing events


    const QSize oldSize = dw->size();
    const int margin = 20;

    dw->setContentsMargins(margin, margin, margin, margin);

    QVERIFY(QTest::qWaitForWindowExposed(&mw));
    qApp->processEvents(); //leave time processing events

    //widget size shouldn't have changed
    QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint());
    //dockwidget should be bigger
    QCOMPARE(dw->size(), oldSize + QSize(margin * 2, margin * 2));


}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:57,代码来源:tst_qdockwidget.cpp

示例4: QMainWindow

Window::Window () : QMainWindow (NULL) {
    try {
        viewer = new GLViewer;
    } catch (GLViewer::Exception e) {
        cerr << e.getMessage () << endl;
        exit (1);
    }
    setCentralWidget (viewer);

#if DEBUG
    cout << "/ ! \\ Building in Debug mode. Performance will be impacted" << endl;
#else
    viewer->setBaseSize(500, 500);
#endif
    
    initControlWidget ();
    
    QDockWidget * controlDockWidget = new QDockWidget (this);
    
    controlDockWidget->setWidget (controlWidget);
    controlDockWidget->adjustSize ();
    addDockWidget (Qt::RightDockWidgetArea, controlDockWidget);
    controlDockWidget->setFloating(true);
    controlDockWidget->setFeatures (QDockWidget::AllDockWidgetFeatures);
    controlDockWidget->adjustSize();
    controlDockWidget->move(0, 0);
    
    QDockWidget * focalDockWidget = new QDockWidget (this);
    focalDockWidget->setWidget(focalWidget);
    focalDockWidget->adjustSize ();
    addDockWidget (Qt::LeftDockWidgetArea, focalDockWidget);
    focalDockWidget->setFloating(true);
    focalDockWidget->setFeatures (QDockWidget::AllDockWidgetFeatures);
    focalDockWidget->adjustSize();
    focalDockWidget->move(200, 0);

    QDockWidget* rayTracerDockWidget = new QDockWidget(this);
    rayTracerDockWidget->setWidget(rayTracerWidget);
    rayTracerDockWidget->adjustSize ();
    addDockWidget (Qt::TopDockWidgetArea, rayTracerDockWidget);
    rayTracerDockWidget->setFloating(true);
    rayTracerDockWidget->setFeatures (QDockWidget::AllDockWidgetFeatures);
    rayTracerDockWidget->adjustSize();

    // Move widgets around the raytracer
    
    QDesktopWidget desktop;
    QRect mainScreenSize = desktop.availableGeometry(desktop.primaryScreen());
    
    controlDockWidget->move(mainScreenSize.width() - 200, 0);
    rayTracerDockWidget->move(0, 0);
    focalDockWidget->move(0, mainScreenSize.height() - focalDockWidget->height());
    
    statusBar()->showMessage("");
}
开发者ID:jcaille,项目名称:Raymini,代码行数:55,代码来源:Window.cpp

示例5: QDialog

/**
 *  Constructs a DlgDisplayPropertiesImp which is a child of 'parent', with the 
 *  name 'name' and widget flags set to 'f' 
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  true to construct a modal dialog.
 */
DlgDisplayPropertiesImp::DlgDisplayPropertiesImp( QWidget* parent, Qt::WindowFlags fl )
  : QDialog( parent, fl )
{
    this->setupUi(this);
    textLabel1_3->hide();
    changePlot->hide();
    buttonLineColor->setModal(false);
    buttonColor->setModal(false);

    std::vector<Gui::ViewProvider*> views = getSelection();
    setDisplayModes(views);
    fillupMaterials();
    setMaterial(views);
    setColorPlot(views);
    setShapeColor(views);
    setLineColor(views);
    setPointSize(views);
    setLineWidth(views);
    setTransparency(views);
    setLineTransparency(views);

    // embed this dialog into a dockable widget container
    Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
    QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
    dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
    dw->setFloating(true);
    dw->show();

    Gui::Selection().Attach(this);

    this->connectChangedObject =
    Gui::Application::Instance->signalChangedObject.connect(boost::bind
        (&DlgDisplayPropertiesImp::slotChangedObject, this, _1, _2));
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:41,代码来源:DlgDisplayPropertiesImp.cpp

示例6:

void tst_QDockWidget::task237438_setFloatingCrash()
{
    //should not crash
    QDockWidget pqdwDock;
    pqdwDock.setFloating(false);
    pqdwDock.show();
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:7,代码来源:tst_qdockwidget.cpp

示例7: AddressInput

MainWindow::MainWindow()
{
	AddressInput* addressInput = new AddressInput( this );
	this->addToolBar( addressInput );

	QDockWidget* motor0Dock = new QDockWidget( "Motor 0", this );
	motor0Dock->setWidget( new MotorWidget( this, 0 ) );
	motor0Dock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
	addDockWidget(Qt::BottomDockWidgetArea, motor0Dock );
	motor0Dock->setFloating( false );
	motor0Dock->setVisible( true );

	QDockWidget* motor1Dock = new QDockWidget( "Motor 1", this );
	motor1Dock->setWidget( new MotorWidget( this, 1 ) );
	motor1Dock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
	addDockWidget(Qt::BottomDockWidgetArea, motor1Dock );
	motor1Dock->setFloating( false );
	motor1Dock->setVisible( true );

	QDockWidget* motor2Dock = new QDockWidget( "Motor 2", this );
	motor2Dock->setWidget( new MotorWidget( this, 2 ) );
	motor2Dock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
	addDockWidget(Qt::BottomDockWidgetArea, motor2Dock );
	motor2Dock->setFloating( false );
	motor2Dock->setVisible( true );

	QDockWidget* odometryDock = new QDockWidget( "Odometry", this );
	odometryDock->setWidget( new OdometryWidget( this ) );
	odometryDock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
	addDockWidget(Qt::BottomDockWidgetArea, odometryDock );
	odometryDock->setFloating( false );
	odometryDock->setVisible( true );

	setCentralWidget( new ControlPanelWidget( this ) );
}
开发者ID:ct2034,项目名称:robotino,代码行数:35,代码来源:MainWindow.cpp

示例8: on_configAction_triggered

void MainWindow::on_configAction_triggered()
{
	QDockWidget * configCameraDock = new QDockWidget( "Camera Configuration", this );
	{
            _configCamera = new ConfigCamera( configCameraDock );
            configCameraDock->setWidget( ( _configCamera ) );
            addDockWidget( Qt::TopDockWidgetArea, configCameraDock );
	}
	configCameraDock->setFloating( true );
}
开发者ID:Elfhir,项目名称:tweedy,代码行数:10,代码来源:MainWindow.cpp

示例9: createDockWidget

QDockWidget* MainWindow::createDockWidget(KoDockFactoryBase* factory)
{
    QDockWidget* dockWidget = 0;

    if(!m_dockWidgetMap.contains(factory->id())) {
        dockWidget = factory->createDockWidget();

        // It is quite possible that a dock factory cannot create the dock; don't
        // do anything in that case.
        if(!dockWidget) return 0;
        m_dockWidgets.push_back(dockWidget);

        dockWidget->setObjectName(factory->id());
        dockWidget->setParent(this);

        if(dockWidget->widget() && dockWidget->widget()->layout())
            dockWidget->widget()->layout()->setContentsMargins(1, 1, 1, 1);

        Qt::DockWidgetArea side = Qt::RightDockWidgetArea;
        bool visible = true;

        switch(factory->defaultDockPosition()) {
        case KoDockFactoryBase::DockTornOff:
            dockWidget->setFloating(true); // position nicely?
            break;
        case KoDockFactoryBase::DockTop:
            side = Qt::TopDockWidgetArea; break;
        case KoDockFactoryBase::DockLeft:
            side = Qt::LeftDockWidgetArea; break;
        case KoDockFactoryBase::DockBottom:
            side = Qt::BottomDockWidgetArea; break;
        case KoDockFactoryBase::DockRight:
            side = Qt::RightDockWidgetArea; break;
        case KoDockFactoryBase::DockMinimized:
            visible = false; break;
        default:;
        }

        addDockWidget(side, dockWidget);
        if(dockWidget->features() & QDockWidget::DockWidgetClosable) {
            m_dockWidgetMenu->addAction(dockWidget->toggleViewAction());
            if(!visible)
                dockWidget->hide();
        }

        m_dockWidgetMap.insert(factory->id(), dockWidget);
    } else {
        dockWidget = m_dockWidgetMap[ factory->id()];
    }

    connect(dockWidget, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(forceDockTabFonts()));

    return dockWidget;
}
开发者ID:foren197316,项目名称:calligra,代码行数:54,代码来源:MainWindow.cpp

示例10: setFloating

void tst_QDockWidget::setFloating()
{
    const QRect deskRect = QApplication::desktop()->availableGeometry();
    QMainWindow mw;
    mw.move(deskRect.left() + deskRect.width() * 2 / 3, deskRect.top() + deskRect.height() / 3);
    QDockWidget dw;
    mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);

    mw.show();
    QVERIFY(QTest::qWaitForWindowExposed(&mw));

    QVERIFY(!dw.isFloating());
    const QPoint dockedPosition = dw.mapToGlobal(dw.pos());

    QSignalSpy spy(&dw, SIGNAL(topLevelChanged(bool)));

    dw.setFloating(true);
    const QPoint floatingPosition = dw.pos();

    // QTBUG-31044, show approximately at old position, give or take window frame.
    QVERIFY((dockedPosition - floatingPosition).manhattanLength() < 50);

    QVERIFY(dw.isFloating());
    QCOMPARE(spy.count(), 1);
    QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
    spy.clear();
    dw.setFloating(dw.isFloating());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    dw.setFloating(false);
    QVERIFY(!dw.isFloating());
    QCOMPARE(spy.count(), 1);
    QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
    spy.clear();
    dw.setFloating(dw.isFloating());
    QCOMPARE(spy.count(), 0);
    spy.clear();
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:39,代码来源:tst_qdockwidget.cpp

示例11: restoreStateOfFloating

void tst_QDockWidget::restoreStateOfFloating()
{
    QMainWindow mw;
    QDockWidget dock;
    dock.setObjectName("dock1");
    mw.addDockWidget(Qt::TopDockWidgetArea, &dock);
    QVERIFY(!dock.isFloating());
    QByteArray ba = mw.saveState();
    dock.setFloating(true);
    QVERIFY(dock.isFloating());
    QVERIFY(mw.restoreState(ba));
    QVERIFY(!dock.isFloating());
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:13,代码来源:tst_qdockwidget.cpp

示例12: testDockWidget

void tst_QWindowContainer::testDockWidget()
{
    QMainWindow mainWindow;
    mainWindow.resize(200, 200);

    QDockWidget *dock = new QDockWidget();
    QWindow *window = new QWindow();
    QWidget *container = QWidget::createWindowContainer(window);
    dock->setWidget(container);
    mainWindow.addDockWidget(Qt::RightDockWidgetArea, dock);

    mainWindow.show();
    QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
    QVERIFY(window->parent() == mainWindow.window()->windowHandle());

    QTest::qWait(1000);
    dock->setFloating(true);
    QTRY_VERIFY(window->parent() != mainWindow.window()->windowHandle());

    QTest::qWait(1000);
    dock->setFloating(false);
    QTRY_VERIFY(window->parent() == mainWindow.window()->windowHandle());
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:23,代码来源:tst_qwindowcontainer.cpp

示例13: QDockWidget

void tst_QDockWidget::task165177_deleteFocusWidget()
{
    QMainWindow mw;
    QDockWidget *dw = new QDockWidget(&mw);
    mw.addDockWidget(Qt::LeftDockWidgetArea, dw);
    QLineEdit *ledit = new QLineEdit;
    dw->setWidget(ledit);
    mw.show();
    QVERIFY(QTest::qWaitForWindowExposed(&mw));
    qApp->processEvents();
    dw->setFloating(true);
    delete ledit;
    QCOMPARE(mw.focusWidget(), (QWidget *)0);
    QCOMPARE(dw->focusWidget(), (QWidget *)0);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:15,代码来源:tst_qdockwidget.cpp

示例14: newChart

void MainWindow::newChart()
{
    QDockWidget * chartDockWidget = new QDockWidget("Chart", this);

    EpidemicChartWidget * epidemicChartWidget = new EpidemicChartWidget(this);

    chartDockWidget->setWidget(epidemicChartWidget);

    addDockWidget(Qt::BottomDockWidgetArea, chartDockWidget);

    chartDockWidget->setFloating(true);

    if(dataSet_ != NULL)
    {
        epidemicChartWidget->setDataSet(dataSet_);
        epidemicChartWidget->setTime(time_);
    }
}
开发者ID:knolla,项目名称:PanFluExercise,代码行数:18,代码来源:MainWindow.cpp

示例15: ViewButtonClicked

void TitleWidget::ViewButtonClicked(void)
{
	QDockWidget* Dock = qobject_cast<QDockWidget*>(parent());

	if (Dock->isFloating())
	{
		if (Dock->geometry() == QApplication::desktop()->availableGeometry(Dock))
		{
			Dock->setGeometry(Dock->property("last-geometry").toRect());
		}
		else
		{
			Dock->setProperty("last-geometry", Dock->geometry());
			Dock->setGeometry(QApplication::desktop()->availableGeometry(Dock));
		}
	}
	else Dock->setFloating(true);
}
开发者ID:Kuszki,项目名称:AVR-Monitor,代码行数:18,代码来源:titlewidget.cpp


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