[Qt-interest] QDockWidget floating/non-floating style sheetissue

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Mon Jun 29 09:00:45 CEST 2009


Hi Santhosh, 

I have just been playing with stylesheets over the weekend.  It has a really
cool feature - accessing properties directly, eg, in a QLabel

qproperty-text: "MyCaption";

So you can modify existing properties, that don't have css equivalents!  

But wait! there's more...

You can override a class and add your own properties, then refer to and set
them via the style-sheet! I used this to provide color changes when hovering
over a QLabel. 

In your case, I would try adding a read-only property that just reflects the
floating state. 

Now if some kind Trolltech person would actually document how to specify
values for ALL of the standard types of properties, eg, qproperty-pixmap:
url(:/images/myimage.png); ... ;O)

Hope that helps, 

Tony,


> Santhosh Y wrote:
> > Hi ,
> >
> > How can I set a style sheet for the dock widget, when it is 
> in floating 
> > or non-floating state.
> >
> > I want to set the floating & non-floating dock widget's 
> background color 
> > to red, green colors respectively.
> >
> > Following style sheet i am setting on qApplicaiton:
> >
> > 
> qApp->setStyleSheet("QDockWidget[floating=false]{background-co
> lor:green}" \
> >                                   
> > "QDockWidget[floating=true]{background-color:red}");
> >
> > But it is not working correctly.
> >
> > What is wrong with this?
> > Any suggestions or completely a different idea for doing the same!
> >
> > Thanks,
> > Santhosh





More information about the Qt-interest-old mailing list