Results 1 to 4 of 4

Thread: Style sheet not applied by inheritance ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2013
    Posts
    38
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Style sheet not applied by inheritance ?

    Hi,

    I have a MyWidget object which inherits from QWidget.

    The following function is supposed to change the background color of a MyWidget object but it does not work.

    Any remarks ?

    Thanks.

    Qt Code:
    1. // Set a color
    2. void MyWidget::setColor(const QColor &color)
    3. {
    4.  
    5. // Prepare the style
    6. QString style = "background-color: rgb(%1, %2, %3);";
    7.  
    8. // Set the color
    9. this->setStyleSheet(
    10. style
    11. .arg(color.red())
    12. .arg(color.green())
    13. .arg(color.blue())
    14. );
    15.  
    16. qDebug() << this->styleSheet();
    17. }
    To copy to clipboard, switch view to plain text mode 

    PS : the debug instruction returns the correct style sheet.
    Last edited by moijhd; 2nd April 2013 at 16:22.

Similar Threads

  1. 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
  2. KDE 3 style applied to Qt 4 programs
    By alecs1 in forum KDE Forum
    Replies: 4
    Last Post: 4th December 2008, 21:24
  3. Style Sheet on QWizard
    By desch in forum Qt Programming
    Replies: 2
    Last Post: 6th December 2007, 17:12
  4. QToolButton and Style sheet
    By desch in forum Qt Programming
    Replies: 8
    Last Post: 1st December 2007, 08:38
  5. How to use style sheet
    By safknw in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2006, 13:05

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
  •  
Qt is a trademark of The Qt Company.