Results 1 to 3 of 3

Thread: QLineEDit back color

  1. #1
    Join Date
    Apr 2021
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question QLineEDit back color

    I've implemented a change the Qapp QPalette which filters down to all my other widgets with the exception of QLineEdit. The background color (QPalette::Base) will not set unless I do it directly on that widget. QTextEdit works fine. I'm wondering if there is some problem with the QLineEdit not inheriting properly or maybe the parent is not set correctly. Any help welcome. Thanks.

  2. #2
    Join Date
    Jun 2012
    Location
    Austria
    Posts
    22
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLineEDit back color

    My feeling is that QPalette support is "not the most consistent". I think the preferred way to change the design nowadays is the styleSheet property. Try something like setStyleSheet("QWidget{background: #ffd8c0}"); on the topmost widget you want to change the color. See https://doc.qt.io/qt-5/stylesheet-reference.html for more explanation.

  3. #3
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLineEDit back color

    Hi, I played a bit with the preview in the Qt Designer, but I was not able to change the background of the QLineEdit with any of the roles. So I agree with stryga42, a stylesheet is probably the only way.

    Ginsengelf

Similar Threads

  1. How could I revert back the escape char. in QLineEdit
    By jemyzhang in forum Qt Programming
    Replies: 2
    Last Post: 23rd May 2015, 12:18
  2. Replies: 1
    Last Post: 17th August 2010, 17:17
  3. Changing Qt's green application back ground color
    By anafor2004 in forum Qt Programming
    Replies: 0
    Last Post: 17th June 2009, 12:58
  4. qCheckbox back ground color
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2006, 19:44
  5. background color of QLineEdit
    By Seema Rao in forum Qt Programming
    Replies: 4
    Last Post: 11th December 2006, 21:40

Tags for this Thread

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.