Qt World Summit: Register Today!

Not able to create my desired sizes and positions with QT Creator layouts

  • Hello Everybody,

    I am designing my UI with ten buttons , a tree model, and two labels on a tab page of a Tab widget. I am not able to set the positions and sizes of my own if design them and set tab widget's layout otions. After creating them in my desired way I tried to set Layout->Layout in a GRID or any other style all the positions and sizes are being changed.

    Can somebody shed light on this ?

  • Could you give us a sketch of what you are trying to achieve?

  • Helo Adre,

    is there any provision to send my image files ??

  • No, you can not upload images to DevNet, but you can link to imaged uploaded elsewhere. You might look into using Dropbox.com, imagebin.org, or any other image sharing service you like.

  • hello Andre,
    Please have a look into my images...

    http://dl.dropbox.com/u/27922800/Changed design with TabWidget's GRID layout.png

    http://dl.dropbox.com/u/27922800/Desired Design before setting GRID layout.png

  • Can you please check the links since they are not working.


  • If you want to hard code the size and positions of the buttons, then you can't use a layout on them. The job of the layout is to automatically arrange child widgets within a widget to ensure that they make good use of the available space, therefore you have to choose to either hard code sizes and positions yourself OR let the layout handle the layout and positioning for you.

  • The images you posted are not publicly viewable, it seems. You need to put them in your public folder of your dropbox, and it is probably best to choose file names that don't have special characters (including spaces).

  • but if I hard code the sizes and positions they are not getting re aligned accordingly with main window's minimize and maximize actions...how can i handle this ?

  • Again: please show us what you want to achieve. That makes it much easier to help you out. If you want your layout to adjust with the resizing of the window, then you need layouts. The standard layouts however do have their limitations. These can sometimes be lifted by implementing your own layouts, but let's see what you are after before recommending such a thing.

    In short: please fix URLS for the images you uploaded, so we can have a look.

  • Desired:
    !http://dl.dropbox.com/u/27922800/DesiredDesignBeforeSettingGRIDlayout.png(Desired design)!

    After using layouts:
    !http://dl.dropbox.com/u/27922800/ChangedDesignWithTabWidgetGRIDlayout.png(Result after using layouts)!

    ..please lemme know if you could look into pics

    Edit: inlined images in posting for easier viewing; Andre

  • Looks like the whole problem is, that your buttons get smaller, right?

    So: why not give them a minimum size? You can do that in designer. Select the button, and modify the minimumSize property available in the QWidget group of properties.

  • In fact if the buttons are themselves in a vertical layout then you only need to modify the minimum size of any one of the buttons. Just to save you some clicking ;-)

  • buttons are getting small and other controls are getting large :-(

  • If you want them to keep relative sizes (not fixed), then you need to work with the horizontalStretch property of the sizePolicy. This allows you to set a ratio between the sizes of the areas.

    I did sometimes notice that this seems to work best between as small a number of widgets as possible. If it doesn't work if you set them directly, try putting your buttons in a QWidget as a container, and your two views too, layout these containers horizontally and set their stretch factors, and then layout the views and the buttons within their respective QWidget containers.

Log in to reply