PDA

View Full Version : get property from qss in runtime



steep8
11th February 2011, 08:35
I have qss file like this :


QSlider::groove:horizontal {

border: 1px solid #999999;

height: 10px;

background: #c4c4c4;

margin: 0px 5px 0 5px;

}

How to get margin property at runtime?, like


int margin_right = getMarginRight();


Its useful to paint custom rectangle like:


const QRect slider_rect_groove = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove , this);

int rect_position_x = slider_rect.right();

int current_width = rect_width * (slider_rect_groove.width() - margin_right)/100 - rect_position_x;

wysota
11th February 2011, 23:29
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++.