Results 1 to 6 of 6

Thread: How to apply style for widget over application style

  1. #1
    Join Date
    Sep 2011
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How to apply style for widget over application style

    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

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to apply style for widget over application style

    try to set the style after the widget is parented.

  3. #3
    Join Date
    Sep 2011
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to apply style for widget over application style

    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

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to apply style for widget over application style

    Qt Code:
    1. QWidget * w = new QWidget;
    2.  
    3. //any of these can reparent the widget.
    4. w->setParent(...);
    5. layout->addWidget(w);
    6. this->setLayout(layout);
    7.  
    8. w->setStyle(...);//This line should be at the end
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Sep 2011
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to apply style for widget over application style

    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

  6. #6
    Join Date
    Sep 2011
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to apply style for widget over application style

    Thank you.
    I got it by taking the children from parent widget
    and applying style to subwidgets.

    Thanks and regards,
    muthu

Similar Threads

  1. Replies: 10
    Last Post: 13th August 2011, 08:10
  2. Replies: 5
    Last Post: 16th December 2010, 11:41
  3. Do Qt Style Sheets support List-style-image?
    By daiheitan in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2010, 01:41
  4. Problems with Gradient style used through Style sheet on ARM platform
    By puneet.narsapur in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th January 2010, 12:48
  5. Replies: 1
    Last Post: 7th February 2007, 00:12

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.