PDA

View Full Version : How to specify widget coordinates (x, y, width, height) using style sheets?



montylee
13th April 2009, 19:45
I know that we can customize the appearance of widgets using style sheets (color, border etc.) but is it possible to specify widget coordinates (x, y, width, height) using style sheets?

I have 5-6 labels. Currently i am using style sheets for the appearance of labels but i have to hard-code the absolute label coordinates. I want to specify those in the style sheet.

Grimlock
13th April 2009, 22:26
AFAIK Style Sheets are for styling purposes only, You'll need to use layouts or setPos ,setSize.

montylee
14th April 2009, 00:14
so this means i can't use style sheets to specify widget coordinates?

Grimlock
14th April 2009, 08:25
Sorry I just had a look it to Assistant there are some Properties You might want to look at:
-height
-width
-position
Just have a look at the Qt Style Sheets Reference

spirit
14th April 2009, 08:28
Sorry I just had a look it to Assistant there are some Properties You might want to look at:
-height
-width

this ok for a widget, but this works (I mean position) only for sub-controls


-position
Just have a look at the Qt Style Sheets Reference

so, I'm afraid that there is no possibility to achieve this by using style sheets.

faldzip
14th April 2009, 10:40
Maybe you can use QSettings with *.ini file where you can keep settings and then apply them to labels, if style sheets are not enough.

montylee
14th April 2009, 17:40
I already went thru the Qt documentation on style sheets and height, width etc. are meant for subcontrols only.
Currently i use a separate file (like .ini) for specifying the position and size of widgets. I was hoping to merge that file into the Qt style sheet but it seems it's not possible to specify position and size of widgets in style sheets.