Resize a dialog box
Hi folks,
How do I create a dialog box with hidden features to appear after a click of a button, like when a user wants to see the advanced options, then clicks an “advance” button and the dialog expands.
I already know how to make the widgets come and go, but I can’t make the window automatically resizes.
I appreciate any help.
11 replies
You might check out this post [qtcentre.org] which I think covers what you’re talking about.
@chetankjain: I believe it is a Qt4-related thing. The example is basically showing how to use QLayout::setSizeConstraint to replace the old Qt3 QDialog::setResizeMode() functionality.
I think resize() is ok if you know a fixed size you want to expand to, but this method allows the QLayout to determine the new size of the dialog. Often, especially when working with i18n and translations, or with differing system themes, you can’t be sure of the size your dialog will need to be without having to do some dirty work with size hints and whatnot.
Whichever way works best is left as an exercise to the programmer. I’m just sharing an alternative that has worked for me.
Thanks a lot,
The chetankjain’s idead works fine, I had to use the trial and error aproach, but it was fun.
mlong did present a more automatic way of doing this, but somehow it doesn’t work! The application suposedly executes but nothing appears on the screen, and after 18 to 20 seconds I get this:
Starting C:\Qt\2010.05\SortDialog-build-desktop\debug\SortDialog.exe…
C:\Qt\2010.05\SortDialog-build-desktop\debug\SortDialog.exe exited with code -1073741819
Runnig in debugging mode returns an error coming from the
layout()->setSizeConstraint(QLayout::SetFixedSize);
It says:
“The inferior stopped because it received a signal from the Operating System.
Signal name: SIGSEGV
Signal meaning: Segnentation fault”
I have no idea of what this means.
ah SIGSEGV … :)
http://en.wikipedia.org/wiki/SIGSEGV [en.wikipedia.org]
Hi folks,How do I create a dialog box with hidden features to appear after a click of a button, like when a user wants to see the advanced options, then clicks an “advance” button and the dialog expands.
I already know how to make the widgets come and go, but I can’t make the window automatically resizes.I appreciate any help.
you can have a look at the example of the docs: dialog extension [doc.qt.nokia.com]
It works without fixed sizes
Thank you Gerolf, it really helped. I used the idea of working with connections, but instead of dealing with multiple layouts I used only a single layout and resized it as required.
Setting a fixed size for the form’s layout in Qt Designer makes the resizing not avaiable to the user and lets the resizing through code a litle bit easier, since I can just put high values and the widget sizer puts it in the ideal size.
That’s the solution I’ll stick to.
Thank you everybody.
You must log in to post a reply. Not a member yet? Register here!




