Results 1 to 4 of 4

Thread: How to reset a stylesheet to default?

  1. #1
    Join Date
    Oct 2010
    Posts
    91
    Thanks
    38

    Default How to reset a stylesheet to default?

    Hello!

    I use a stylesheet to draw a red border around QLineEdits if the QValidator fails. So far this works fine. But I could not figure out how to reset the stylesheet to the default one. The style is returned to its default on a valid input, but not if the field is emptied.

    I read somewhere that one could use

    Qt Code:
    1. lineEdit->setStyleSheet(styleSheet());
    To copy to clipboard, switch view to plain text mode 

    but this does not work...

    Do you know how I can fix this?

    Kind regards,
    HomeR

  2. #2
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to reset a stylesheet to default?

    hi,
    try
    pushButton->setStyleSheet("");

    Bala

  3. The following user says thank you to BalaQT for this useful post:

    homerun4711 (17th February 2011)

  4. #3
    Join Date
    Oct 2010
    Posts
    91
    Thanks
    38

    Default Re: How to reset a stylesheet to default?

    Thanks for your answer.
    As I just found out, both methods work:

    Qt Code:
    1. lineEdit->setStyleSheet(styleSheet());
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. lineEdit->setStyleSheet("");
    To copy to clipboard, switch view to plain text mode 

    But in my case the problem was somewhere else: the styleSheet-reset was overwritten by another setStyleSheet called by a signal-slot connection and thus it not change. *stupid*stupid*

    Kind regards,
    HomeR

  5. #4
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to reset a stylesheet to default?

    hi,
    good to hear you solved the problem

Similar Threads

  1. Replies: 7
    Last Post: 12th January 2011, 22:01
  2. Default stylesheet of QGroupBox
    By mstegehu in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2010, 08:44
  3. Replies: 1
    Last Post: 9th February 2010, 12:11
  4. Bug in Qt4.3.3 QXmlSimpleReader::reset() ?
    By Shawn in forum Qt Programming
    Replies: 9
    Last Post: 3rd March 2008, 09:14
  5. QImage reset
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2007, 10:18

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.