Results 1 to 4 of 4

Thread: QDockWidget moves the position of QWidget

  1. #1
    Join Date
    Apr 2020
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QDockWidget moves the position of QWidget

    Hello everyone,

    We're developing a UI and since last month we used qt 5.8.0 libraries. Now we upgraded to 5.14.1 and everything seemed fine, until we analyzed the UI with the windows SDK inspect tool.

    Turns out that the UI looks fine to the eye, but actually the central widgets positions are shifted down right, according to Windows. That is because buttons and switches work fine, when clicked with the mouse cursor, but the inspect tool says that the position is not what I'm looking at.
    I'm blaming something on the QDockWidget because the central part is shifted right about the same width of the QDockWidget.
    For the bottom direction shift, probably has something to do with the tab bar (the Status button is the button of a QTab widget which has only one tab) but had no confirmation yet.

    The yellow square is the position found by the inspect tool and it should start where the red arrow is pointing, covering all the main interface. The distance between the QDockWidget and the yellow square is the exact width of the QDockWidget (rounded in green)
    Capture.jpg

    The interface is all coded in C++ and running on Windows 10, compiled using Visual Studio 2017 with the msvc2017 kit. We are not using ui files, sadly.

    I've tried removing parents from QDockWidget constructor, removing the DockWidget (and that fixes the right position shift but not the down shift Capture_nodock.jpg) but the DockWidget is necessary. Hiding the QDockWidget title with
    Qt Code:
    1. m_pDockLeft->setTitleBarWidget(new QWidget());
    To copy to clipboard, switch view to plain text mode 
    and the title is hidden but the position of the widget still remains shifted. I'm stuck with this issue and can't figure out what to do or to try, so I'm open to suggestions and/or advice on what to look and what to do.

    Thanks in advance and sorry for any lack of informations.

  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: QDockWidget moves the position of QWidget

    You probably need to show some code on how you are constructing your QMainWindow and the layouts / widgets within it. How you set up the menus, toolbars, status bar, etc. are irrelevant, but the construction of your centralWidget is important.
    <=== 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
    Apr 2020
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QDockWidget moves the position of QWidget

    Hello,

    yes, the code is quite complicated and basically, the issue was that the central widget was not hereditating the parent, making that son of another widget and thus, shifting in a wrong direction.
    If you think it's interesting for some other people in the future I can find the time to post the code. Otherwise, this thread can be locked and marked as solved

  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: QDockWidget moves the position of QWidget

    the issue was that the central widget was not hereditating the parent, making that son of another widget
    If you have a QWidget-based class that contains all of the UI inside of the QMainWindow frame (the area inside the tool bars, menu bars, status bar, and left / right sides), you should be calling QMainWindow::setCentralWidget() with the pointer to that widget instance. That automatically makes the main window the parent of the QWidget class. If you are not calling setCentralWidget(), then that is an error.

    If the central widget for the main window has been set correctly, then QMainWindow will automatically take care of resizing and moving the central widget when dock widgets are docked and undocked.
    <=== 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: 5
    Last Post: 6th January 2017, 21:57
  2. Add QWidget to QDockWidget
    By Jack_Holmes in forum Newbie
    Replies: 2
    Last Post: 18th December 2015, 14:17
  3. QDockWidget Tab Position!
    By neosettler in forum Qt Programming
    Replies: 0
    Last Post: 15th February 2014, 07:08
  4. QDockWidget moves out of screen
    By Randulf in forum Qt Programming
    Replies: 3
    Last Post: 29th May 2007, 12:30
  5. QDockWidget tab position & style
    By efontana in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2007, 14:38

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.