Correct use of Widgets



  • 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


  • Moderators

    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).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.