Results 1 to 7 of 7

Thread: DockWidget not moving inside QWidget ?

  1. #1
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default DockWidget not moving inside QWidget ?

    I am using QDesigner to create a new form. I want this form to be a widget window, not a main window, because it will be called from some other windows. So, I am defining them to be moveable etc, but when I make them and run them, they don't move at all. You can make them float, but not move them. I checked the dockwidget example, and the only noticeable difference I found was, that the example uses the addDockWidget function, whereas the automatically created from QtDesigner header file does not. I experimented with it(commenting this function in the example) and indeed the dock widgets stopped movind. Therefore, I tried to call it in my program, but I realized that this function exists only for QMainWindow.

    Is this actually the reason for the dock widgets not to be able to move ? If yes, is there any way to call this function inside a QWidget inherited class ?

  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: DockWidget not moving inside QWidget ?

    You can have multiple "main windows" even if it's called like that. QMainWindow is the only class that supports dock widgets. If you want to use dock widgets in a sensible way, you must design a main window.
    J-P Nurmi

  3. #3
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: DockWidget not moving inside QWidget ?

    Ok, thanx.

    If I want though, to have dock widgets in the centre area, can I ? Because only the Left, Right etc of the MainWindow are available.

    In general, is there any reason for only MainWindow having Dock widgets ?

  4. #4
    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: DockWidget not moving inside QWidget ?

    In theory, you can place QDockWidget anywhere you could place any other QWidget. In practice, it won't act like a dock widget if you place it elsewhere than in QMainWindow, just like you have already noticed. So QMainWindow really is the only sane place. QMainWindow has a special layout that can handle dock widgets, toolbars etc. It will make some room when moving a dock widget over a dockable area etc. Ordinary QWidget cannot handle such thing, it's just an empty window and nothing more.

    As mentioned, QMainWindow is not limited to one instance. You can even put one QMainWindow inside another if you want to. Just notice that "Creating a main window without a central widget is not supported. You must have a central widget even if it is just a placeholder."
    J-P Nurmi

  5. #5
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: DockWidget not moving inside QWidget ?

    Yeah, I would just like my central widget to be composed by dock widgets, in order to be able to move them nicely, like dockwidgets do. Can the cetranl widet inherit as well the QMainWindow ? I guess yes.

  6. #6
    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: DockWidget not moving inside QWidget ?

    Quote Originally Posted by aurelius View Post
    Can the cetranl widet inherit as well the QMainWindow ? I guess yes.
    Yes, but the inner one still needs a place holder as its own central widget. And unfortunately it won't be possible to undock from one main window and dock to another... This issue has been discussed on the forums before, I don't remember if someone came up with a solution.
    J-P Nurmi

  7. #7
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: DockWidget not moving inside QWidget ?

    Yeah I understand. Meyabe it's unrealistic, I don;t know, but it would be a nice feature, if the central widget could also be a dock widget. Tha is, except for the Left/Right Dock area, to have also centre dock area.

Similar Threads

  1. QWidget inside MFC project
    By hINTModuleState in forum Newbie
    Replies: 3
    Last Post: 9th October 2015, 15:22
  2. switch a QWidget inside a QMainWindow to fullscreen
    By koenux in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2009, 21:25
  3. Replies: 2
    Last Post: 29th May 2007, 13:55
  4. moving QWidget and Mainform
    By mickey in forum Newbie
    Replies: 9
    Last Post: 6th April 2006, 17:54
  5. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 22:59

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.