Results 1 to 5 of 5

Thread: background color of QLineEdit

  1. #1
    Join Date
    Feb 2006
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default background color of QLineEdit

    Hi all,

    Can some body explain how to set the back ground color of QLineEdit? By default it appears white, how to change it to gray?

    Thanks in advance,
    Seema Rao

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: background color of QLineEdit

    Please try to search the forums before asking:
    http://www.qtcentre.org/forum/showthread.php?t=2196#3
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: background color of QLineEdit

    Play with setPalette and setBackgroundRole or search in forum, there were many threads alike this
    a life without programming is like an empty bottle

  4. #4
    Join Date
    Dec 2006
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: background color of QLineEdit

    If you are using Qt 4.2 you can take advantage of the Qt Style Sheets:

    Qt Code:
    1. ui.edtBox->setStyleSheet( QString( "background-color: gray"));
    To copy to clipboard, switch view to plain text mode 

    ... and at least one of your concerns have been gone in a second ...

  5. #5
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: background color of QLineEdit

    Quote Originally Posted by zlatko View Post
    Play with setPalette and setBackgroundRole or search in forum, there were many threads alike this
    Just a heads up: I used the 4.1.3 and previous designers to set the pallete for about 40 lineedits. My problem was that when they were disabled the users were complaining that the content was hard to read. So, I set the "disabled" palette to show BLACK text, not grey. When I upgraded to 4.2.1 and then 4.2.2 I could no longer compile my app because I was generating errors:
    "e:\hap2006\ui_homestead.h(6380):
    fatal error C1509: compiler limit : too many exception handler states
    in function 'Ui_homesteadUi::setupUi'. simplify function"
    which support said was due to:
    It is because in your ui file you change a lot of palettes and fonts and
    the generated code creates a brush for each of the roles in the
    palette. Since you change a lot of them it hits a limit with the
    MSVC compiler which is why it does not build.
    It seems that Trolltech was creating an entire palette set for each control, and when it got up to around 1600 sets MSVC++ 2003 couldn't handle it any more.

    This has been posted with Qt and the support staff told me it would be in the next release:

Similar Threads

  1. Replies: 3
    Last Post: 8th December 2006, 19:51
  2. QFrame and its background
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2006, 21:32
  3. QLabel background color
    By munna in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 16:36
  4. background colour
    By kw in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2006, 01:44
  5. Replies: 1
    Last Post: 5th April 2006, 17:44

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.