Results 1 to 2 of 2

Thread: Docking multiple ui files to the main window

  1. #1
    Join Date
    Mar 2017
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Docking multiple ui files to the main window

    I have a main window in a ui file I am using. I have made multiple other ui widget files and would like to dock next to, above and below the main window.

    I tried to do this with dock widget but it just put them inside of the main window, and it looked all garbled up.

    What is correct way to dock multiple widgets to the main window?

  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: Docking multiple ui files to the main window

    If you want dock widgets to attach outside the main window, then you have to make them top-level widget (in other words, create them with parent = 0, not parent = your main window instance).

    Since these are top-level windows, if you want them to be "docked" to the sides of the main window, you will have to do that manually. If I were doing it, I would implement a method in MainWindow that is called from the resizeEvent() and moveEvent(): if main window is visible, move your "docked" widgets so they stay attached to the edges of the main window, wherever you want them. You'll need to take into account the overall sizes of all of the widgets (including their window frames) and their screen positions. It isn't hard, but it will probably take you a few tries to get all the geometry correct.
    <=== 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.

Similar Threads

  1. Replies: 2
    Last Post: 17th February 2011, 13:30
  2. Replies: 11
    Last Post: 11th August 2008, 10:14
  3. Ctrl key to allow user to stop docking a window
    By irudkin in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2007, 05:42
  4. Replies: 15
    Last Post: 23rd March 2007, 17:16
  5. Replies: 6
    Last Post: 18th August 2006, 18:50

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.