Results 1 to 7 of 7

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

  1. #1
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to specify widget coordinates (x, y, width, height) using style sheets?

    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.

  2. #2
    Join Date
    Nov 2008
    Location
    Częstochowa/Poland
    Posts
    50
    Thanks
    2
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to specify widget coordinates (x, y, width, height) using style sheets?

    AFAIK Style Sheets are for styling purposes only, You'll need to use layouts or setPos ,setSize.

  3. #3
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to specify widget coordinates (x, y, width, height) using style sheets?

    so this means i can't use style sheets to specify widget coordinates?

  4. #4
    Join Date
    Nov 2008
    Location
    Częstochowa/Poland
    Posts
    50
    Thanks
    2
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to specify widget coordinates (x, y, width, height) using style sheets?

    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

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to specify widget coordinates (x, y, width, height) using style sheets?

    Quote Originally Posted by Grimlock View Post
    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
    Quote Originally Posted by Grimlock View Post
    -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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to specify widget coordinates (x, y, width, height) using style sheets?

    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.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  7. #7
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to specify widget coordinates (x, y, width, height) using style sheets?

    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.

Similar Threads

  1. QLayout: different SizeConstraints for width and height?
    By PhilippB in forum Qt Programming
    Replies: 0
    Last Post: 23rd February 2009, 17:33
  2. style widget on canvas (qgv)
    By valtovar in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2008, 01:31

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.