Results 1 to 4 of 4

Thread: textEdit background color

  1. #1
    Join Date
    Oct 2009
    Location
    tathra nsw australia
    Posts
    14
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Cool textEdit background color

    G'day all

    How can i set the background color in lineEdit, textEdit, ect to
    red. then how to make it a flashing red...

    thanks in anticipation
    briang

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Wink Re: textEdit background color

    I use stylesheet property in QtCreator. The flash effect you could probably do with a timer.

    ps: googling 'set background QLineEdit' resulted in some decent examples

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

    briang (23rd October 2009)

  4. #3
    Join Date
    Sep 2009
    Location
    London
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: textEdit background color

    hey brian, there are couple of ways to do, it all depends on what exactly you need to style.

    My experience is using Qt Designer, so if you are familiar with it thats' great - if you aren't, then its a great opportunity for you to have a look at it.



    If its for instance to style all QLineEdits and and QTextEdit, open designer...

    1. create the UI as needed
    2. Right-Click on the top-level object
    3. Once you right click, a "set stylehsheet" option should appear
    4. just write
    ".QLineEdit, .QTextEdit
    {
    background-color: red;
    }"
    5. and thats it!(images attached for further guidance)

    Note: adding the "." before the object name as i did, will make the style to be applied universally to every QLineEdit(or whatever object you choose) in the UI .


    thanks,
    Attached Images Attached Images

  5. The following user says thank you to Erik_Klein for this useful post:

    briang (6th November 2009)

  6. #4
    Join Date
    Feb 2007
    Posts
    73
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: textEdit background color

    If you're not using the gui builder, you can do the following:
    Qt Code:
    1. QLineEdit *edit = new QLineEdit;
    2. QPalette p = edit.palette();
    3. p.setColor(QPalette::Base, Qt::red);
    4. edit->setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    Look at the documentation for QPalette too.
    Last edited by smacchia; 5th November 2009 at 17:31.

  7. The following user says thank you to smacchia for this useful post:

    briang (6th November 2009)

Similar Threads

  1. Replies: 2
    Last Post: 17th July 2010, 21:07
  2. Replies: 1
    Last Post: 11th September 2009, 17:03
  3. button background color when it is clicked
    By navi1084 in forum Qt Programming
    Replies: 4
    Last Post: 9th December 2008, 15:02
  4. Help text color in TextEdit
    By tho97 in forum Qt Programming
    Replies: 5
    Last Post: 26th March 2008, 08:47
  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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.