PDA

View Full Version : Can I layout widgets by using StyleSheet?



MorrisLiang
3rd May 2010, 15:36
So,Can I use stylesheet to layout my widgets?
For example,I want myFrame(QFrame) set to x:30px,y:30px.And I also want to set the width&height.In this way,people can theme my app by themselves.

But I think it's probably not possible...I need verification.:)

MorrisLiang
3rd May 2010, 15:54
I finally figure it out myself.
for somebody who wants to know how,see the stylesheet below:

QFrame{
background: url(:/Pics/TitleBG.png) no-repeat;
qproperty-geometry:rect(0 0 252 35);
}

set the qproperty-geometry to be rect(x,y,width,height).

Lykurg
3rd May 2010, 16:36
I am not sure what application you are doing, but please don't layout your widgets manualy. Use layouts for that! They are much better than manual layout!!! See QHBoxLayout for example and make yourself familiar with the layout concept of Qt...

MorrisLiang
4th May 2010, 11:46
Yeah,I know Layout is good.But the interface of the app I'm building is not so complex.And if I manualy layout my widgets,I can use stylesheet to theme my app better.

tbscope
4th May 2010, 12:20
Maybe you want to use QML (or Qt Quick)