Results 1 to 3 of 3

Thread: QTextEdit line background color

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question QTextEdit line background color

    How to set background color for line (not text) in QTextEditor.

    Example, every line start with text "DEPRECATED" will set background color red.

    use QTextCharFormat only fill background for text

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit line background color

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit line background color

    But, why the background color remove when I move cursor??

    appendPlainText(QString("TAHEDE %1 ").arg(text));

    moveCursor(QTextCursor::End);
    moveCursor(QTextCursor::StartOfLine);


    QTextEdit::ExtraSelection h;
    h.cursor = textCursor();
    h.format.setProperty(QTextFormat::FullWidthSelecti on, true);
    h.format.setBackground(Qt::green);

    QList<QTextEdit::ExtraSelection> extras;
    extras << h;
    setExtraSelections(extras);

Similar Threads

  1. Replies: 0
    Last Post: 3rd July 2013, 18:51
  2. Draw line with inverted background color
    By viswanath in forum Qt Programming
    Replies: 4
    Last Post: 12th November 2011, 03:57
  3. Qt4 - QTextEdit - background color
    By impeteperry in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2009, 07:52
  4. how to change QTextEdit background color ?
    By mismael85 in forum Qt Programming
    Replies: 9
    Last Post: 26th June 2008, 22:05
  5. Slot to color background of line edit on textedited
    By tpf80 in forum Qt Programming
    Replies: 5
    Last Post: 21st June 2007, 09:02

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.