Results 1 to 2 of 2

Thread: centralWidget and QDockWidgets in designer

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default centralWidget and QDockWidgets in designer

    Hi,
    I am going through the designer manual provided with Qt-4.2.x. This is the first time I am trying to design userinterfaces with designer. I exclusively used code to achieve this in the past. Now, I've come across a little problem with designer. When coding, I would instantiate a QWidget object and set it as the centralWidget using QMainWindow::setCentralWidget() ... Then I would define the other elements and lay them out on this centralWidget, using whatever Layout is appropriate. Adding QDockWidgets was equally simple using QMainWindow::addDockWidget(). The defined centralWidget would automatically expand to take up the space between the menu- and Statusbar. Now with designer, the centralWidget is predefined and there is no way, I can directly access it. If I add widgets to the MainWindow Form, the widgets do not automatically take up the space reserved for the centralWidget, even though they are clearly marked as children of the centralWidget in the object inspector.

    That can be easily solved when applying a layout to the form itself. This probably means that the layout is not applied to the QMainWindow (which would be wrong anyway, since QMainWindows already have a Layout ... ) but to the centralWidget. So far so good. But when I try to drag QDockWidgets onto the form, they are placed WITHIN the centralWidget as opposed to being added to the QMainWindow itself. to put it differently, I am looking for the Drag & Drop equivalent of QMainWindow::addDockWidget() ... .Any hints?

    Thanx in advance
    momesana

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: centralWidget and QDockWidgets in designer

    Try adding the dock widget by the time when the top level layout has not yet been set. Otherwise the dock widget seems to end up into the layout. Change the dock widget's properties (docked, dockWidgetArea) after dropping it on the form (docked property comes visible only when the dock widget is not in a layout and dockWidgetArea property comes visible after setting the docked property to true).

    About the central widget, Designer handles it like you suspect. The central widget is created automatically and the top level layout is set on the central widget.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    momesana (18th December 2006)

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.