Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Correct use of Widgets

    General and Desktop
    2
    2
    481
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aidoru last edited by aidoru

      Hello,
      I created a qt application project where I have:

      • A main widget
      • Inside the main widget I have a OpenGLWidget and a DockWidget.

      To manage the OpenGLWidget I created a sub-class and promoted the widget to use it.

      To manage the DockWidget I Didn't create any sub-classes and I manage it in the main widget class:

      MainWidget::MainWidget(QWidget *parent)
      	: QWidget(parent)
      {
      	ui.setupUi(this);
      	ui.dockWidget = new QDockWidget(tr("MyDockWidget"), this);
      	ui.dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
              ...................................
              ........................
      

      But I don't think it is the correct use because with that code it created 2 dock widget: dockWidget (and that is ok) and another dock widget called as my main widget.

      Could someone tell me which is the correct use of a dock widget created in designer?

      Thank you

      1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion last edited by

        If you created it in the designer there is no need to create one manually. Just use the one created in the designer, you can access it via ui->dockWidget (or what ever name you gave the widget in the designer).

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • First post
          Last post