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.
-
You might check out "this post":http://www.qtcentre.org/wiki/index.php?title=Expanding_dialog 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 -1073741819Runnig 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":http://en.wikipedia.org/wiki/SIGSEGV -
[quote author="Delay" date="1299977299"]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.[/quote]
you can have a look at the example of the docs: "dialog extension":http://doc.qt.nokia.com/4.7/dialogs-extension.html
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.
-
All your links are broken. So, did i need to open a new question on the same subject, or follow here and comments links became no more relevant will be removed ?
I also want to be able to extend dialog box window, but directly for the window can contain all the widget/containers. (for example, i dynamically add widgets who contains views on some other containers (groupBox), and then dimensions change when dynamic insertion happens... so lot of them become out of dialog box view (and then cut).
I'm searching for a solution for the dialog box will automatically change his dimension for see all the full containers included.
Thank you. -
@jerome_isAviable You should not expect all links to be valid after 5 years.
And invalid links should not be removed because you would modify old posts so it will become more difficult to follow the thread history. Instead you can add new links.
For this link http://doc.qt.nokia.com/4.7/dialogs-extension.html
I just googled for "qt dialog extensions" and found this: http://doc.qt.io/qt-5/qtwidgets-dialogs-extension-example.html -
@jsulm "You should not expect all links to be valid after 5 years."
why do you think that "i should expect all links to be valid after 5 years" ?
tell that "i should expect" is a choice from your mind invention, because nothing relevent would show that "i should expect".
I just signal that links are all broken... what's wrong with that ? are you serious man ? keep calm please.But also, the link you share here is something i read allready and not answer to the target question to... so i definitly not understand why you answer like that.
You affirm to know what "should" be or not... not only for yourself, but for all other... Do i should tell you thank you for that to ?
Also, if you "just googled" it is your choice to "just googled", maybe some other don't want to use google (who are you for tell people what they should do and thinking ? God himself ?).
In the same way, i can answer: "why not just paste links you find, why choose to write an answer so agressive ?"
Please do respect people who has not necessary the obligation to think same than you and just said signal things, just do it for show you can be able to respect people, and then, be respectable.
Thank you for change tonality of your answer in the way of respect (or ignore me please). -
@jerome_isAviable tone of voice is a hard thing online. Most of us here are not native english speakers, writing in our second or third language.
The general trend is to write in short sentences that contain only the essential. This comes over in many cultures as slightly offensive, something that it is not meant to be. Making interpretations on wording when there are two translations in between (the original poster from their native language in which they think and you to your native language) is mostly useless.
As for your original question, open a new thread, as this one is five years old. Most people on this thread will probably not follow it anymore.
-
@tekojo thank you for take time for this answer, that is fine.
Sure, from communication proffessionals on communication, in all langages, answer that: "you should this, you should that..." or "I just do that and..." (why "just" ? what is the signification back to this kind of formulation ? my english friends filling like me... tell me that it is a pretentious answer), and except to use specific tools that people not have to use too, is like to tell them: "you are stupid" and "you have to do same me, because i think i am the best and i want it like that".No one want to be traited like that, definitely.
I really more appreciate your mediation way of answer, who is pretty nice.
thank you again for your mediation intervention.
-
@jerome_isAviable you are welcome.
Hope you get an answer to your resize problem.
-
Not sure about what you try to do, so.. let me know if my answer help you or not:
for alert error message, you can use QMessageBox this way:
on conditional error test happen, just open QMessageBox the easy way:
bool error(true); QString my_data("just for have a look"); if(error) { QMessageBox::warning(this, tr("my title on top bar window dialog here"), tr("my error message with data: %1).arg(my_data)); }
and that's all. look at Qt API for QMEssageBox, there is different alert method to... and also, from there you have allready 2 buttons inside the dialog box, you can also change the text of button, and interact with the answer easy. This is well describe in the API of QMessageBox.
if you want to catch events from button (i don't know for do what... but why not ?) you need to connect signal from QMessageBox you create to a SLOT (see on QObject member function: "connect" for that).
you can also add buttons to easy and catch event with "switch()" C++ function because QMessageBox give back a int type of answer related to the button clicked.