Results 1 to 4 of 4

Thread: QPlainTextEdit selection color?

  1. #1
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QPlainTextEdit selection color?

    kind of a dumb question..

    the default color of selected text (when dragging the mouse over text) is not to my liking (its almost invisible)
    how can i change the default color?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QPlainTextEdit selection color?

    You can set a style sheet:

    Qt Code:
    1. QTextEdit { selection-background-color: darkblue }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPlainTextEdit selection color?

    how can i do it from within the code?
    ( im really new to qt )

    edit:
    never mind, found it
    Last edited by jajdoo; 18th July 2010 at 09:36.

  4. #4
    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: QPlainTextEdit selection color?

    You can use QWidget::setStyleSheet(). But for such a simple task I'd prefer using QPalette. Assuming textEdit is a pointer to your editor:
    Qt Code:
    1. QPalette p = textEdit->palette();
    2. p.setColor(QPalette::Highlight, QColor(/*what ever you want*/);
    3. p.setColor(QPalette::HighlightedText, QColor(/*what ever you want*/);
    4. textEdit->setPalette(p);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Using a QFrame as a color selection indicator
    By KShots in forum Qt Tools
    Replies: 8
    Last Post: 14th June 2011, 23:55
  2. Replies: 1
    Last Post: 22nd February 2010, 09:38
  3. Replies: 3
    Last Post: 22nd January 2010, 16:46
  4. Display Label Color by selecting Color Picker
    By sosanjay in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2009, 06:11
  5. Selection color
    By jnana in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2006, 13:28

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.