Results 1 to 7 of 7

Thread: QDialog dynamic size.

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QDialog dynamic size.

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

  3. The following user says thank you to wysota for this useful post:

    hickscorp (26th April 2007)

  4. #3
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog dynamic size.

    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?

  5. #4
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog dynamic size.

    Quote Originally Posted by hickscorp View Post
    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..

    Qt Code:
    1. lineedit = editperson->findChildren<QLineEdit *>();
    2. boxlist = editperson->findChildren<QComboBox *>();
    3. doubnum = editperson->findChildren<QDoubleSpinBox *>();
    4. numerlist = editperson->findChildren<QSpinBox *>();
    5. datelist = editperson->findChildren<QDateTimeEdit *>();
    6.  
    7. /* table a start fill */
    8. for (int i=0;i<lineedit.size();i++){
    9. basedata->FillText(lineedit[i]);
    10. }
    11. for (int i=0;i<numerlist.size();i++) {
    12. basedata->FillNumer(numerlist[i]);
    13. }
    14. for (int i=0;i<boxlist.size();i++) {
    15. basedata->FillBox(boxlist[i]);
    16. }
    17. for (int i=0;i<datelist.size();i++) {
    18. basedata->FillDate(datelist[i]);
    19. }
    20. /* table a stop */
    21.  
    22. next table from his id...
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog dynamic size.

    Quote Originally Posted by hickscorp View Post
    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.

  7. The following user says thank you to wysota for this useful post:

    hickscorp (26th April 2007)

  8. #6
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog dynamic size.

    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.

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog dynamic size.

    You mean Quick Time? I think it's their primary software technology...

Similar Threads

  1. Restrict size of QLineEdit
    By bruccutler in forum Newbie
    Replies: 2
    Last Post: 19th March 2007, 16:31
  2. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  3. Replies: 1
    Last Post: 24th October 2006, 16:40
  4. Replies: 6
    Last Post: 5th March 2006, 21:05
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.