Results 1 to 6 of 6

Thread: Problem while Docking/Undocking of the QDockWidget on the default mainwindow "Central

  1. #1
    Join Date
    Jul 2010
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem while Docking/Undocking of the QDockWidget on the default mainwindow "Central

    Hi Friends,

    I am facing the problem while Docking/Undocking of the QDockWidget on the default mainwindow "CentralWidget". I am using method "setCentralWidget()" to setting the dockwidget on the main window.

    But when I dock it and trying to undock again then it does not worked.

    Is there any known way to deal with this problem?

    Note: I have tried to set the float behavior using mouse double click as:

    setFloating(false) &
    setCentralWidget(...);

    But it doesn't work.

    I have attached my example along with this post.

    Thanks...
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem while Docking/Undocking of the QDockWidget on the default mainwindow "Cen

    Dock widgets are meant to be used around the central widget. Your implementation more or less asks for quirky behavior... What behavior do you want to achieve? Try to explain without mentioning dock windows. Just make some screen shots and choose a few easy-to-type-about names to clarify. Maybe someone can offer you a better solution to what you're trying to achieve.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

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

    pastispast (29th November 2010)

  4. #3
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem while Docking/Undocking of the QDockWidget on the default mainwindow "Cen

    I imagine what you'd want to do is call setCentralWidget and pass in the child widget of the QDockWidget. As franz says, QDockWidgets occupy the space around the QMainWindow's central widget. I could understand that you'd want to use a widget contained in a QDockWidget as the central widget, but you'd then need to do something with the widget that is already being used as the central widget and you'd need to do something with QDockWidget that used to contain the widget that is now the central widget.

    Things to remember is that a QMainWindow always needs to have a central Widget.

    If you've got multiple widgets that could occupy the MainWindow's central widget area, then maybe your central widget should rather be a QTabWidget which could then contain multiple "central" widgets. You could then add functionality that removes a widget from the QTabWidget and puts it in a floating QDialog and vice versa. No reason why you couldn't also remove a widget from the QTabWidget and put it in a floating QDockWidget and vice versa, but then you wouldn't really be using a QDockWidget as intended.

    Might also be worthwhile looking into a MDI interface (see QMdiArea).

    A few random ideas, but I've got myself thinking now. I'll need to do something along these lines with my app at some point soon. I'll get back if I come up with anything that works nicely.

  5. The following user says thank you to stefanadelbert for this useful post:

    pastispast (29th November 2010)

  6. #4
    Join Date
    Jul 2010
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem while Docking/Undocking of the QDockWidget on the default mainwindow "Cen

    Quote Originally Posted by franz View Post
    Dock widgets are meant to be used around the central widget. Your implementation more or less asks for quirky behavior... What behavior do you want to achieve? Try to explain without mentioning dock windows. Just make some screen shots and choose a few easy-to-type-about names to clarify. Maybe someone can offer you a better solution to what you're trying to achieve.
    Thanks franz...

    Actually I have problem regarding to the positioning of the QDockWidget on the QMainWindow. I have 3 dockwidget in my main window [initially centre widget I put as 0]:

    maindock: left side
    rightdock: right side
    bottomdock: bottom side

    I have to position the dockwidget in some ratio (Say 3/4 width for maindock, 1/4 width for left dock and 100 px height for bottom widget).

    Now I want that when I close the "rightdock" and "bottomdock", then "maindock" should take the place of others, but reverse should not possible(i.e. when close "maindock" then "rightdock" and "bottomdock" should not resize). All the dockwidgets
    should have the docking features.

    To achieve this I have used the approach that I have mention in my initial post (i.e. if maindock will be member of the centre
    widget then I can achieve this, but the problem comes here...)

  7. #5
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem while Docking/Undocking of the QDockWidget on the default mainwindow "Cen

    So basically you want rightdock and bottomdock to be fixed size, and maindock to be expanding?
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  8. #6
    Join Date
    Jul 2010
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem while Docking/Undocking of the QDockWidget on the default mainwindow "Cen

    Quote Originally Posted by franz View Post
    So basically you want rightdock and bottomdock to be fixed size, and maindock to be expanding?
    Hi franz thanks for the reply...Actually I don't want that "rightdock" and "bottomdock" to be fixed size but it can be re-size by the user, but automatic they should not dock when maindock close(As dock feature). But both should have dock effects(like float etc...).

Similar Threads

  1. QDockWidget/Central Widget Problem
    By Lemming in forum Qt Programming
    Replies: 7
    Last Post: 3rd April 2016, 09:52
  2. QDockWidget : docking, reopening after closing
    By kghose in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2008, 20:22
  3. QDockWidget freezes desktop when undocking
    By pdolbey in forum Qt Programming
    Replies: 5
    Last Post: 12th March 2007, 14:47
  4. Replies: 6
    Last Post: 18th August 2006, 17:50
  5. different arrangement of QDockWidget than default
    By Wurgl in forum Qt Programming
    Replies: 3
    Last Post: 13th July 2006, 10:41

Tags for this Thread

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.