How to update QWizard geometry after page change?



  • This is how I designed one of my QWizardPages in QtCreator:
    picture
    Then I've filled it with data, in class' constructor:
    code
    That's the effect:
    video
    My problem is obvious: I don't want it to be possible to resize QWizard the way it will mess current QWizardPage up. Also, I want QWizard to change it's geometry when needed to some sane value. I've tried to put updateGeometry() everywhere I could but it didn't help. I don't like the idea of setting minimum sizes for each window, also because the text is just temporary and will be changed, possibly translated too... what's the simplest way to fix the issue?



  • @dijuna Qt widgets and layouts are meant to be resized. It isn't a good idea to limit that especially because of what you already mentioned with different sizes due to different languages.

    You can specify a default size for your window and then let the user resize as they prefer. Your widgets should also fit on the window properly as long as it isn't some very small size or lots of widgets crammed in there.

    For the 2 widgets that were getting squished to the point of illegibility, I would set a minimum size for those. The rest looked good during the resizing on the video.

    All that being said you can of course set a fixed size and disable sizing of your wizard. Not a recommended approach.



  • @ambershark that was what I've said: I don't want to set minimum sizes, I don't want to limit user's ability to resize the window; within sane values. Not only QRadioButtons are the problem: please note QLabels on the right, only last two of them had full text visible - all the others were trimmed. I could set minimum sizes for them but the text is long, the minimum size would have to be big... and the text could be shorter in the future, much shorter. I can't see any good approach here.



  • @dijuna said in How to update QWizard geometry after page change?:

    @ambershark that was what I've said: I don't want to set minimum sizes, I don't want to limit user's ability to resize the window; within sane values. Not only QRadioButtons are the problem: please note QLabels on the right, only last two of them had full text visible - all the others were trimmed. I could set minimum sizes for them but the text is long, the minimum size would have to be big... and the text could be shorter in the future, much shorter. I can't see any good approach here.

    That's really your only option. If there isn't space to show a widget it gets squished like that. So you limit what the user can do with a minimum window size, or you let them size themselves into unreadable widgets.

    For the text you can use something that is scrollable if you are going to have large amounts of text in those areas. QLabels are meant as, well labels. Small pieces of text to label things. For bigger amounts you want a read only QTextEdit or something that can handle larger amounts.



  • That's really your only option. If there isn't space to show a widget it gets squished like that.

    That's not default behaviour of widgets created fully in designer. If I would copy labels' text values from CPP to UI file, it would set sane size hints and I wouldn't need to do a thing for the window to look as it should: it would open bigger and restrict user from resizing; allowing the user to set window's size to be of any value is NOT default and desired behaviour, and I don't know single application which does that the way you described. The problem only exists if you want to set the values on the fly: to do it by hand, you would need to use QFontMetrics and go from there but that's too much work and I was wondering if the way designer does it can be recreated in some simple way... and that's what I'm asking here.

    For bigger amounts you want a read only QTextEdit or something that can handle larger amounts.

    The amounts we are talking about are in QLabel's range; they can be even short two-liners, and the problem persists. I could just put the labels into QScrollAreas but that's not the behaviour I want to achieve.

    I resolved my problem for the most part, by playing with size policy and nesting layouts within layouts but I will leave this question as unsolved, awaiting better approach.



  • @dijuna said in How to update QWizard geometry after page change?:

    That's really your only option. If there isn't space to show a widget it gets squished like that.

    That's not default behaviour of widgets created fully in designer. If I would copy labels' text values from CPP to UI file, it would set sane size hints and I wouldn't need to do a thing for the window to look as it should: it would open bigger and restrict user from resizing; allowing the user to set window's size to be of any value is NOT default and desired behaviour, and I don't know single application which does that the way you described. The problem only exists if you want to set the values on the fly: to do it by hand, you would need to use QFontMetrics and go from there but that's too much work and I was wondering if the way designer does it can be recreated in some simple way... and that's what I'm asking here.

    I don't use the designer to make my windows but I could test this real quick and see if it is happening to me too. I don't have these issues with my Qt apps. It could be something you are doing wrong with your layouts that I don't do or something.

    It's also possible I don't notice it because the majority of my development is linux. My products are for major corporations though and used by many people in linux, osx, and windows. So I think QA departments or customers would have reported weird sizing issues.

    For bigger amounts you want a read only QTextEdit or something that can handle larger amounts.

    The amounts we are talking about are in QLabel's range; they can be even short two-liners, and the problem persists. I could just put the labels into QScrollAreas but that's not the behaviour I want to achieve.

    Ok definitely don't switch to QTextEdit's then if they are that short. I notice QLabels don't handle sizing the best though at smaller sizes, but they should stay legible.

    I resolved my problem for the most part, by playing with size policy and nesting layouts within layouts but I will leave this question as unsolved, awaiting better approach.

    This makes sense.. I was thinking you had layout issues if that was happening. Again since I don't use designer and I still don't have these issues with my apps, I'm guessing it is a layout thing you are doing.

    Glad you have it worked out (somewhat) though. :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.