Results 1 to 3 of 3

Thread: QLCNumber background color

  1. #1
    Join Date
    Dec 2009
    Posts
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QLCNumber background color

    This code (on Qt 4.6)

    QPalette Pal = ui->lcdNumber->palette();
    Pal.setColor(QPalette::Normal, QPalette::WindowText, Qt::green);
    Pal.setColor(QPalette::Normal, QPalette::Window, Qt::black);
    ui->lcdNumber->setPalette(Pal);

    changes the digits to green OK but has no effect on the background color, which remains light grey.

    Why not ?
    How can i change the background color ?

    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QLCNumber background color

    You code for the palette is fine. So try to use QWidget::autoFillBackground.
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication app(argc, argv);
    6.  
    7. QLCDNumber lcd(&w);
    8. lcd.setAutoFillBackground(true);// see the different if you comment that line out.
    9.  
    10. QPalette Pal = lcd.palette();
    11. Pal.setColor(QPalette::Normal, QPalette::WindowText, Qt::green);
    12. Pal.setColor(QPalette::Normal, QPalette::Window, Qt::black);
    13. lcd.setPalette(Pal);
    14.  
    15.  
    16. w.show();
    17.  
    18. return app.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 12th December 2009 at 13:20. Reason: updated contents

  3. The following 2 users say thank you to Lykurg for this useful post:

    Cotlone (30th July 2011), waynew (28th December 2009)

  4. #3
    Join Date
    Dec 2009
    Posts
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLCNumber background color

    that was it

    thanks

Similar Threads

  1. button background color when it is clicked
    By navi1084 in forum Qt Programming
    Replies: 5
    Last Post: 24th June 2024, 12:09
  2. Replies: 2
    Last Post: 17th July 2010, 21:07
  3. Replies: 1
    Last Post: 11th September 2009, 17:03
  4. setting background color of QMessageBox
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 23rd May 2009, 13:26
  5. QLabel background color
    By munna in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 15:36

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.