Results 1 to 8 of 8

Thread: resize Dialog to minimum height

  1. #1
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default resize Dialog to minimum height

    I have a dialog with a tabwidget which can be enabled or disabled (hidden)

    If the tabwidget is hidden the dialog must not take the whole space it
    had with the tabwidget.
    It should rather be resized to minimum height. this however did not
    work. I tried the following:
    Qt Code:
    1. if (state == Qt::Checked)
    2. tabWidget_FullOptions->setHidden(false);
    3. else {
    4. tabWidget_FullOptions->setHidden(true);
    5. this->resize(this->sizeHint().width(),
    6. this->minimumSizeHint().height());
    7. }
    To copy to clipboard, switch view to plain text mode 
    However the resize does not happen, or has no effect.
    So how do I resize a Dialog to its minimum height?

    Matthias

  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

    Default Re: resize Dialog to minimum height

    You can only do that automatically by setting a size constraint on its layout.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: resize Dialog to minimum height

    Quote Originally Posted by wysota View Post
    You can only do that automatically by setting a size constraint on its layout.
    Sorry, I have no idea what you mean. Can you give me a hint towards the corresponding function in QWidget?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: resize Dialog to minimum height

    As a normal procedure one should open assistant and use its search function. As you was told something about "size" and "constraint" try to use the phrases "sizeconstraint" or "constraintsize" and as you want to set this try "setsizeconstraint" or "setconstraintsize". One will lead you to the function!

    Or may you look at our wiki (searching "dialog"): Expanding dialog

  5. #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: resize Dialog to minimum height

    Quote Originally Posted by pospiech View Post
    Sorry, I have no idea what you mean. Can you give me a hint towards the corresponding function in QWidget?
    If you are posting a question in the section of the forum called "Qt Programming" and your profile states you are an intermediate Qt user, I'm assuming you know how to use Qt Assistant, how to write C++ code and how to solve basic problems related to your programs. If you don't fall into this category and you want a direct solution, please instead post in the "Newbie" forum which is there for the purpose. If you know how to handle a fishing pole, post in Qt Programming. If you're only after the fish, post in the Newbie section.

    Sorry for being so rude and straightforward but the amount of questions asking for direct solutions has recently increased significantly and of course nobody considers himself a newbie. So consider this a moderator message, not a regular board user reply.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: resize Dialog to minimum height

    Quote Originally Posted by Lykurg View Post
    Or may you look at our wiki (searching "dialog"): Expanding dialog
    You mean:
    Qt Code:
    1. layout()->setSizeConstraint(QLayout::SetFixedSize);
    To copy to clipboard, switch view to plain text mode 
    Well, I was asking because it was not in the list of QWidget functions, but looking deeper it shows up in QLayout.

    This does the resizing. However also in width, and sets the size to fixed. That is much more than I wanted. I wanted it to be resized to minimum height without changes to the size constrain. If that is not possible I could live with size constrain.

    Quote Originally Posted by wysota View Post
    If you are posting a question in the section of the forum called "Qt Programming" and your profile states you are an intermediate Qt user, I'm assuming you know how to use Qt Assistant, how to write C++ code and how to solve basic problems related to your programs.
    First of all, yes I agree with you. If you feel that trivial questions (rating of trivial though is difficult to measure) should only be placed in the Newbie section I do not mind if you move the thread. But what did I do - I provided my inital trial, and asked for a solution and would implicitly like to know why mine did not work. Your answer introduced a complete concept of Qt of handling things. I responded because I did not see the connection to my question.

    And yes I had looked into the documentation (QAssistent). But the docs very seldom provides solutions to problems (still they are a superb reference).
    Here I found several functions dealing with the Size. So for example there are:
    - void adjustSize ()
    - void resize ( const QSize & )

    I did not understand what the first does, so I tried the second. And in my post I explained how I had tried to get a solution. Size Constrain is a concept I had no heard of before

    Now I know that there is a size constrain thing, but I still do not know how to resize to minimum height, without changing the size constrain.

  7. #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: resize Dialog to minimum height

    Quote Originally Posted by pospiech View Post
    Well, I was asking because it was not in the list of QWidget functions, but looking deeper it shows up in QLayout.
    That's why I said to set a constraint on a layout.

    This does the resizing. However also in width, and sets the size to fixed. That is much more than I wanted. I wanted it to be resized to minimum height without changes to the size constrain. If that is not possible I could live with size constrain.
    You can set a different size constraint...

    And yes I had looked into the documentation (QAssistent). But the docs very seldom provides solutions to problems (still they are a superb reference).
    Sure they do, people just look in one place and if don't find the solution there, they assume it can't be nowhere else too. Using the search in Assistant (and not only the index) often helps but most people don't bother trying.

    Now I know that there is a size constrain thing, but I still do not know how to resize to minimum height, without changing the size constrain.
    You can always call
    Qt Code:
    1. resize(width(), minimumSizeHint().height());
    To copy to clipboard, switch view to plain text mode 
    but you have to do that manually.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: resize Dialog to minimum height

    Any resizing does not work anymore, after I made the dialog to a Mdisubwindow.

    Now with the size constrain meantioned here, the widget is with correct height, but centered into the Dialog window with 200px above and below left empty.

    If I set the widget to full size (make the hidden part visible) it takes the space available before.

    If I use resize with 'minimumSizeHint().height()', then the height value changes between 300 and 700 but the resize command has no effect.

    The reason for this error, is that all commands apply to the widget, not the surrounding Dialog.

    So how do I ensure that the dialog (from QMdiSubWindow) is resized and not only the containing widget?

Similar Threads

  1. Resize the height of QTabWidgets
    By tarod in forum Qt Programming
    Replies: 3
    Last Post: 28th July 2008, 12:48
  2. Qidget height resize if child widgets invisible
    By visor_ua in forum Qt Programming
    Replies: 1
    Last Post: 27th April 2008, 11:27
  3. Replies: 2
    Last Post: 22nd January 2008, 16:10
  4. Resize all components in a dialog
    By bdQtdev in forum Qt Tools
    Replies: 5
    Last Post: 10th January 2008, 10:13
  5. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41

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.