Results 1 to 2 of 2

Thread: QDock widget size

  1. #1
    Join Date
    Aug 2008
    Location
    Cherry Hill, NJ USA
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDock widget size

    Can someone point me in a direction to do the following:

    I have an Open Inventor render area in a QDockWidget. I'd like the size of the dock widget to be fixed when docked, but resizable when floating...

    Can a layout in the main window do this?

    Thanks,
    Martin

  2. #2
    Join Date
    Aug 2008
    Location
    Cherry Hill, NJ USA
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: QDock widget size

    In answer to my own question:

    Qt Code:
    1. connect(
    2. gui->dockWidget,
    3. SIGNAL(topLevelChanged(bool)),
    4. this,
    5. SLOT(on_floatingChanged(bool)));
    To copy to clipboard, switch view to plain text mode 

    Then:

    Qt Code:
    1. void Docking:: on_floatingChanged(bool floating)
    2. {
    3. QSize guiSize = gui->frameSize();
    4. QSize dockSize = gui->dockWidget->frameSize();
    5.  
    6. dockSize = gui->dockWidget->frameSize();
    7.  
    8. if (floating)
    9. {
    10. int width = guiInitialSize.width() - dockWidgetInitialSize.width();
    11. gui->resize(width, guiInitialSize.height());
    12. }
    13. else
    14. {
    15. gui->resize(guiInitialSize.width(), visGuiInitialSize.height());
    16. }
    17.  
    18. guiSize = gui->frameSize();
    19. dockSize = gui->dockWidget->frameSize();
    20. dockSize = gui->dockWidget->frameSize();
    21.  
    22. } // on_floatingChanged
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 23rd December 2008 at 21:40. Reason: missing [code] tags

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. Resize Widget To Desktop Size
    By fruzzo in forum Qt Programming
    Replies: 6
    Last Post: 2nd October 2008, 15:29
  3. QLayout and the size of the widget
    By jimfan in forum Qt Programming
    Replies: 2
    Last Post: 20th December 2007, 17:04
  4. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 13:12
  5. Size of a plugin widget in designer
    By high_flyer in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2006, 13:29

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.