Results 1 to 2 of 2

Thread: get property from qss in runtime

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

    Default get property from qss in runtime

    I have qss file like this :
    Qt Code:
    1. QSlider::groove:horizontal {
    2.  
    3. border: 1px solid #999999;
    4.  
    5. height: 10px;
    6.  
    7. background: #c4c4c4;
    8.  
    9. margin: 0px 5px 0 5px;
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 
    How to get margin property at runtime?, like
    Qt Code:
    1. int margin_right = getMarginRight();
    To copy to clipboard, switch view to plain text mode 

    Its useful to paint custom rectangle like:
    Qt Code:
    1. const QRect slider_rect_groove = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove , this);
    2.  
    3. int rect_position_x = slider_rect.right();
    4.  
    5. int current_width = rect_width * (slider_rect_groove.width() - margin_right)/100 - rect_position_x;
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: get property from qss in runtime

    Style sheets are a custom engine that bypasses C++. There is no way to query for a particular property of qss. If you want such information available, code it in C++.
    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.


Similar Threads

  1. QML: Property Z on listViews
    By kuemeele in forum Qt Programming
    Replies: 5
    Last Post: 2nd December 2010, 16:28
  2. Help with property browser
    By Jsvc in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2010, 01:49
  3. qt script property
    By wookoon in forum Qt Programming
    Replies: 2
    Last Post: 28th September 2010, 10:41
  4. Replies: 1
    Last Post: 25th September 2010, 08:20
  5. enum property
    By illuzioner in forum Qt Tools
    Replies: 10
    Last Post: 22nd August 2006, 21:47

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
  •  
Qt is a trademark of The Qt Company.