Dock Widgets Example Question



  • I read http://doc.qt.nokia.com/latest/mainwindows-dockwidgets.html and would like to create an UI exactly like it.

    Except:

    1. centralWidget "Letter" put on right hand side, 2 DockWidgets "Customers" and "Paragraphs" put on left hand side.
    2. There is a bottom DockWidget.

    However, the following code put "Customers" on left hand side, "Letter" on the central, "Paragraphs" on the right hand side.

    How should I change the code to fix the layout problem?

    @
    QFrame *frame = new QFrame( this );
    QLayout *layout = new QVBoxLayout( frame );
    frame->setLayout( layout );
    layout->addWidget( &m_Main );
    setCentralWidget( frame );

    m_A = new A( this );
    addDockWidget( Qt::LeftDockWidgetArea, m_A );
    
    m_B = new B( this );
    addDockWidget( Qt::LeftDockWidgetArea, m_B );
    
    m_C = new C( this );
    addDockWidget( Qt::BottomDockWidgetArea, m_C );
    

    @



  • Dock widgets are freely placeable in the dock areas (either by code or by dragging the widget around). I don't understand the problem you see.

    The letter is in the example placed in the central widget because it makes sense. You should probably be able to place the letter in a dock widget as well if that is what you want. I don't know what the effect will be though. I never tested the approach without a central widget.


  • Moderators

    bq. I don’t know what the effect will be though. I never tested the approach without a central widget.

    I have tried this some time ago and it is not possible without central widget. There should be an empty widget at least



  • Sorry, I am very new to QT. How should the above code (empty central widget) be changed?


Log in to reply
 

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