PDA

View Full Version : How to apply style for widget over application style



muthu-ms
19th October 2011, 13:27
I am setting one custom proxystyle as application style.
I want another custom style for my listwidget. so i have written another style class.
I applying the custom style to the widget using
listwidget->setStyle(new customproxystyle())
But the customproxystyle is not applying to my listwidget instead the application's custom style is applying.
How to override the application level style by widget level,
I am applying style scroll bar, implemented inside drawcomplexcontrol function,
But the style class of app level drawcomplexcontrol function only gets called.

How to apply the custom ctyle for listwidget whenever needed using style class.

Thanks,
muthu

nish
19th October 2011, 14:11
try to set the style after the widget is parented.

muthu-ms
20th October 2011, 07:12
Sorry, I not able to understand "try to set the style after the widget is parented" means?
Can u explain it clearly.

Thanks and regards
muthu

nish
20th October 2011, 08:25
QWidget * w = new QWidget;

//any of these can reparent the widget.
w->setParent(...);
layout->addWidget(w);
this->setLayout(layout);

w->setStyle(...);//This line should be at the end

muthu-ms
20th October 2011, 11:56
I have tried the code,

QWidget * w = new QWidget;
w->setParent( ui.listWidget );
layout->addWidget( w );
this->setLayout( layout );
w->setStyle( new myWidgetStyle() );

But I am unable setStyle For the Widget.
The drawComplexControl function is called only if i set the CusomStyleClass in Applicationlevel.
Eventhough i didnt set any app level style, and applying the style class only for the widget, the drawComplexControl function is not called and the style is not applied.

The CustomStyle is applied only if i set the Style class in application Level.

Thank you,
Regards,
muthu

muthu-ms
21st October 2011, 08:16
Thank you.
I got it by taking the children from parent widget
and applying style to subwidgets.

Thanks and regards,
muthu