Results 1 to 3 of 3

Thread: QMainWindow and its QDockWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Question QMainWindow and its QDockWidget

    Hi everybody,
    I have a simple QMainWindow with a QDockWidget (a tool box) and a central widget (see the joined file called MainWindow1.jpg I don't know how to insert them directly in the text).
    When I click on one button of the tool box, I need to change the central widget of the main window :
    Qt Code:
    1. QPushButton *quit = new QPushButton(tr("&Quit"));
    2. quit->setFont(QFont("Times", 18, QFont::Bold));
    3. quit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    4.  
    5. delete centralWidget();
    6. setCentralWidget(quit);
    7.  
    8. updateGeometry();
    9. update();
    To copy to clipboard, switch view to plain text mode 

    But the problem is that the dock widget (the tool box) now takes a half of the main window horizontaly !!!! (see MainWindow2.jpg)

    To avoid the resizing of the dock widget I wrote the following code:

    Qt Code:
    1. setMinimumWidth(m_toolBox->width());
    2. setMaximumWidth(m_toolBox->width());
    To copy to clipboard, switch view to plain text mode 

    The result was not what I expected : the dock widget is correctly resized but there is a kind of frame taking a half of the main window !!!! (see MainWindow3.jpg)

    Somebody have an idea?
    Attached Images Attached Images

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.