Results 1 to 2 of 2

Thread: Issue with Layout of Wizard Dialog

  1. #1
    Join Date
    Oct 2017
    Posts
    18
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Issue with Layout of Wizard Dialog

    Hi there,

    I am developing a Qt app for the display of plots on Linux (RHEL7) and with Qt 5.9. I'm facing layout problems with a wizard dialog I implemented. The core issue is that when the contents of the wizard dialog change in some cases the size of the dialog window itself would have to change too, e.g. because the new wizard page's contents need more horizontal or vertical space. But this does not always happen.

    I use the wizard dialog in two different contexts:

    1. For the creation of a new plot. Here the first wizard page allows for specification of the plot's type, the second then asks for the to be created plot's properties like the dimensions of x and y axis and others. The second page requires significant more vertical space than the first page. Upon click on the wizard's "Next" button the wizard's vertical size grows as much as needed to make the second page fit into the available space which is fine!

    2. I reuse the wizard for editing of an already existing plot's properties. In this scenario the first page which is shown in the wizard dialog is the one which is shown as second page in the plot creation scenario. To my big surprise the wizard dialog's size is not adjusted to the size required by that page when it is used as
    first page. Instead parts of the contents are vertically squeezed (see screenshot).

    Layout Problem Edit Plot Wizard Page.jpg

    Interestingly when clicking with the left mouse button on a widget in the sqeezed wizard window this results in an immediate resize of the dialog to the proper size. The same happens when I move the cursor (and thus the focus) away from the wizard dialog.

    I could not yet figure out what I can do to enforce the layout calculation programmatically that would lead to a larger size of the wizard dialog in the second usage scenario.
    Any helpful hint would be highly appreciated.

  2. #2
    Join Date
    Oct 2017
    Posts
    18
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Issue with Layout of Wizard Dialog

    Hi there,

    thanks to a post of user d_stranz on another posting from me (https://www.qtcentre.org/threads/697...erences-Dialog) I found a solution for the problem described above too. Just like with my preferences dialog I implemented the slot method showEvent() for my sub-class of QWizard and now the wizard page shows up in proper size with no contents "squeezed" anymore.
    But unfortunately this measure has a side effect. Now the wizard dialog gets placed in the upper left corner of the screen instead centered over the application's main window. I checked the position information calling the pos() method of QWidget in the body of the showEvent() method and it is really 0,0.
    I wounder if there might be a way to avoid this wrong placement but if not, how could I compute the proper position (centered over the application's main window)? I assume that I could simply call move() with that position to fix the problem.

    Found a code snippet that does the proper placement of my dialog centered over the application's main window:

    Qt Code:
    1. QPoint dialogCenter = mapToGlobal(rect().center());
    2. auto *parentWin(static_cast<QWidget*>(parent())->window());
    3. QPoint parentWindowCenter(parentWin->mapToGlobal(parentWin->rect().center()));
    4. move(parentWindowCenter - dialogCenter);
    To copy to clipboard, switch view to plain text mode 

    It is placed in the overridden showEvent() method in my QDialog sub-class to "repair" the wrong placement of my dialog which is the result of this code (placed in the showEvent() method too:

    Qt Code:
    1. setMinimumSize(sizeHint());
    To copy to clipboard, switch view to plain text mode 

    So the only open question left over is: Why is that necessary at all?
    Last edited by apatwork; 3rd September 2018 at 11:58.

Similar Threads

  1. Replies: 0
    Last Post: 14th February 2012, 16:43
  2. Replies: 1
    Last Post: 29th September 2011, 12:14
  3. Resizeable Dialog/Layout (like Dolphin)
    By kiss-o-matic in forum Qt Programming
    Replies: 2
    Last Post: 21st December 2009, 00:18
  4. Resizing dialog with form layout
    By elizabeth.h1 in forum Qt Programming
    Replies: 2
    Last Post: 30th August 2009, 20:58
  5. QT4 layout of complex dialog is very slow
    By cboles in forum Qt Programming
    Replies: 15
    Last Post: 28th April 2006, 20:57

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.