Facing problem to arrange UI items.



  • Hi,
    This could be a very basic question but I am kind of stuck and not having any clue how to proceed further.
    I am creating a UI which has lot of items e.g. checkBoxs, comboBoxs, labels, textEdit, RadioButtons etc. I have added them successfully but the challenge I am facing is they are getting spread all over the widget based on the space available but I want to keep them where I want. I tried vertical / Horizontal/ Grid layouts but all are arranging automatically which I don't like. I even tried GroupBox but did not get the exact look I want.

    Just to mention I am not using Qt Designer and don't want to use it because I am learning Qt that I feel this is the best way to learn :).

    My questions are,

    • Is there any way to specify the exact position in the widget where I want the item to be appear?
    • Is it possible to disable auto adjust options in layouts. Not sure if this sounds weird :) but some how I hate this auto adjust.


  • [quote author="mady" date="1325057308"]

    My questions are,

    • Is there any way to specify the exact position in the widget where I want the item to be appear?
    • Is it possible to disable auto adjust options in layouts. Not sure if this sounds weird :) but some how I hate this auto adjust.
      [/quote]

    You can always use absolute positioning while displaying widgets (e.g., move a widget to a position), but I will not use it. Layouts are good since they adjust the widgets as the main window (or container widgets) changes. Why don't you use a spacer to mangle the space remaining so that it is not used by your widgets?



  • If you want to decide where widgets appear exactly, and you feel layouts don't grand you enough freedom, then it is up to you to manage their positioning manually. Only you know how you want your layout to react to changes in form geometry, right? So Qt cannot help you there.

    If you want my advice: get used to using layouts. They are really quite powerful, and they have sane defaults for things like margins and spacings. It really saves you a lot of headaches, and it will make your applications that much more portable (what happens if at another platform, your widgets are slightly smaller or bigger because you are using a different style or font?)



  • Moreover, since you are learning Qt, learn it well. I don't know any windowing system that does not provide some kind of layout managers, as well as direct positioning. But in the long distance layout-ing pays much more!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.