Results 1 to 5 of 5

Thread: dockWidget not undocking in centralWidget

  1. #1
    Join Date
    May 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows

    Default dockWidget not undocking in centralWidget

    Hey guys!

    I would like to have a dockWidget positioned in the middle of my MainWindow. So what I did was:

    QVboxLayout *grid = new QVBoxLayout(centralWidget());
    grid->addWidget(ui->initial_dockWidget);

    This achivied what i need because it did open the dock maximized in centralWidget as i want.

    However, I can't undock the dock my dragging it. I can undock only by doubleclick or by pressing float button. Does anybody knows how to fix it?

    Thanks

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: dockWidget not undocking in centralWidget

    No wonder. You are misusing dock widgets. They are not added to the central widget, they are added to the QMainWindow itself using QMainWindow::addDockWidget(). QMainWindow has an entire protocol in its internal implementation for handling dock widgets, docking, undocking, tabbed / non-tabbed, etc.. You can't just plop a dock widget down anywhere in your widget hierarchy and expect it to work the same way.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    May 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: dockWidget not undocking in centralWidget

    I know that, but I need to have a centralDock. Using the centralWidget works fine with docks for me if I don't use the layout. Without the layout the dragging-undock works fine, but not with the Layout. I use the layout because the dock has a picture inside and it should open maximized to show the whole picture, and this only works if I use the layout.

    Capture.jpg

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: dockWidget not undocking in centralWidget

    I know that, but I need to have a centralDock.
    No, you don't. You need a central widget to satisfy the requirements for using QMainWindow. You need to design a custom QWidget that has the layout and behavior you want and use that as the central widget. Just because a QDockWidget -looks- like something you could use, and just because you -can- add a layout directly to QMainWindow doesn't mean it is going to behave as you wish (but seem unwilling to accept).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    May 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: dockWidget not undocking in centralWidget

    I got it. I thought that this 'hack' would be efficient, but as you're saying, the QDockWidget will not work as a expect. Would you know how I could implement the dragging movement from scratch then?

Similar Threads

  1. DockWidgets with no centralWidget
    By drave in forum Newbie
    Replies: 2
    Last Post: 1st February 2017, 19:09
  2. Undocking Problem a Bug?
    By qtoptus in forum Qt Programming
    Replies: 7
    Last Post: 17th March 2014, 03:52
  3. Cant get QMainWindow().centralwidget....
    By tonnot in forum Newbie
    Replies: 2
    Last Post: 8th December 2011, 00:49
  4. Replies: 5
    Last Post: 30th November 2010, 06:40
  5. QDockWidget freezes desktop when undocking
    By pdolbey in forum Qt Programming
    Replies: 5
    Last Post: 12th March 2007, 14:47

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.