PDA

View Full Version : QDialog dynamic size.



hickscorp
26th April 2007, 22:00
Hello,

I have a very simple question, so i'm going to do an easy explaination of what i want to achieve:
- i Have a QDialog, with various QFrames in it.
- The QDialog is not made directly via code (It is a .ui which is then converted to CPP).
- All of the content of this QDialog are put in a Vertical Layout (I'm not doing this, i have done the set up in Designer, so it is made in code after i convert from UI to CPP).
- Then when the QDialog runs (And depending on user actions), some of the contained elements can be hidden / shown.

What i want is, each time i hidde / show parts of the content, the QDialog to resize to the MINIMUM size possible (Force all the content to be minimum too).

So i tried so many things, does someone know what i have to do (I guess each time i change visibility of content) programmatically?

Thanks a lot for your time!
Pierre.

wysota
26th April 2007, 22:43
http://wiki.qtcentre.org/index.php?title=Expanding_Dialog

hickscorp
26th April 2007, 23:06
Wysota,

i saw this, but the problem is, the dialog i'm talking about is constructing the layout in from the .ui, and i dont know how to access (get a ptr) to the layout object to do the size constraint...

From my code (A class which herits from the generated CPP), maybe i can use findChildren<QVerticalLayout*> which theorically will return only one item in list (Since there is only one layout over my whole QDialog)?

The thing is, i have ideas, but i'm not sure if it's "clean" and bug free...

Thank you a lot for pointing this article anyway :)
Pierre.

[EDIT:] The layout pointer which is generated in the CPP file is named "vboxLayout" and is public. So my new question is, is this name "vboxLayout" some "nomenclature" which i can be 100% sure will have the same name in future version of QT?

patrik08
26th April 2007, 23:22
Wysota,

i saw this, but the problem is, the dialog i'm talking about is constructing the layout in from the .ui, and i dont know how to access (get a ptr) to the layout object to do the size constraint...

From my code (A class which herits from the generated CPP), maybe i can use findChildren<QVerticalLayout*> which theorically will return only one item in list (Since there is only one layout over my whole QDialog)?
The thing is, i have ideas, but i'm not sure if it's "clean" and bug free...
Thank you a lot for pointing this article anyway :)



findChildren is bug free ... this is a super access function ... i have generated Ui file direct
from db (self build on qt generate qtui, latex pdf forms, scribus forms phyton, && xml) and i have construct a class container to take db->fieldname qt->objektname db->data .... and i fill form from two table on 0.344 sec..



lineedit = editperson->findChildren<QLineEdit *>();
boxlist = editperson->findChildren<QComboBox *>();
doubnum = editperson->findChildren<QDoubleSpinBox *>();
numerlist = editperson->findChildren<QSpinBox *>();
datelist = editperson->findChildren<QDateTimeEdit *>();

/* table a start fill */
for (int i=0;i<lineedit.size();i++){
basedata->FillText(lineedit[i]);
}
for (int i=0;i<numerlist.size();i++) {
basedata->FillNumer(numerlist[i]);
}
for (int i=0;i<boxlist.size();i++) {
basedata->FillBox(boxlist[i]);
}
for (int i=0;i<datelist.size();i++) {
basedata->FillDate(datelist[i]);
}
/* table a stop */

next table from his id...

wysota
26th April 2007, 23:39
i saw this, but the problem is, the dialog i'm talking about is constructing the layout in from the .ui, and i dont know how to access (get a ptr) to the layout object to do the size constraint...
Each object created from ui file is a member of the UI, so you can access it directly though the pointer.


[EDIT:] The layout pointer which is generated in the CPP file is named "vboxLayout" and is public. So my new question is, is this name "vboxLayout" some "nomenclature" which i can be 100% sure will have the same name in future version of QT?

You already have the ui, so it's name won't change. All objects in ui files are assigned to a member of the generated class which is named after the objectName property. It's a global convention, so I'm pretty sure it'll stick. And if not, you can always access the object through its name.

BTW. It's Qt, not QT. The latter is Apple technology.

hickscorp
26th April 2007, 23:44
Oooh very good. Well it answer my question, i'll stick to using the pointer name i got from the CPP generated from the UI.

And about the Apple thing, i'm not surprised at all and glad to learn this came "from" them ^^

Thanks again!
Pierre.

wysota
27th April 2007, 00:34
You mean Quick Time? I think it's their primary software technology...