Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextEdit text color auto restore. [Solved]
Forum Updated to NodeBB v4.3 + New Features

QTextEdit text color auto restore. [Solved]

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bigbangvn
    wrote on last edited by
    #1

    Hi everyone,
    I use QTextEdit and set text color :
    setTextColor(QColor(255,255,255));

    The color changed ok. But after i cleared the text in QTextEdit, the text color become black (its default color of QTextEdit).
    How to change the default text color of QTextEdit?

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      have a look at
      "setCurrentCharFormat":http://qt-project.org/doc/qt-5.0/qtwidgets/qtextedit.html#setCurrentCharFormat

      This wil set wat you want for new text.
      As I understand setTextColor only sets the color for the current selection.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bigbangvn
        wrote on last edited by
        #3

        Hi Eddy, I have tried :
        @ m_subtitleText = new QTextEdit("");
        QTextCharFormat charFormat = m_subtitleText->currentCharFormat();
        charFormat.setFontItalic(true);
        charFormat.setUnderlineColor(Qt::white);@

        Same result, text color, underline color restore to default (black) after i clear the text.
        The font setting is ok.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bigbangvn
          wrote on last edited by
          #4

          Oh, i found that the familiar funtion SetStyleSheet is ok. I think it's not ok and don't try before :).

          @ m_subtitleText->setStyleSheet( tr("QTextEdit{color:%1}").arg(color.name()) );@

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #5

            Does that mean that you solved the problem? If so, please mark the thread as [Solved].)

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bigbangvn
              wrote on last edited by
              #6

              Ok,
              i have used both : setTextColor() , and setStyleSheet().

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved