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 Option use Error.
Forum Updated to NodeBB v4.3 + New Features

QTextEdit Text Option use Error.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 471 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.
  • P Offline
    P Offline
    Pada_
    wrote on last edited by Pada_
    #1

    I modified QTextEdit to change the size, font, and color of the text.

    After creating the contents, change the attributes (size, font, color) and press the return key (Ctrl + Z), the previous attributes are not maintained and the 20th color is returned to black again.

    Is there a way to keep it?

    QTextCharFormat newFormat;
    newFormat.setFont(font);
    newFormat.setFontPointSize(fontSize);
    newFormat.setFontWeight(isBold ? QFont::Bold : QFont::Normal);
    newFormat.setFontUnderline(isUnderLine);
    newFormat.setFontItalic(isitalic);
    newFormat.setForeground(color);

    textEdit->setFont(font);
    textEdit->setCurrentCharFormat(newFormat);
    

    Then, when you write the text again, the first character will return to font size and color 20. However, from the second letter, it will be displayed in the size and color set above.

    How do I make changes to the first one?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What version of Qt are you using ?
      On what platform ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What version of Qt are you using ?
        On what platform ?

        P Offline
        P Offline
        Pada_
        wrote on last edited by
        #3

        @SGaist

        Windows 8 64Bit
        Windows 10 64Bit
        Linux

        Qt 5.4

        The platform does not seem to matter. It seems to be because there is no code that can put the old one back when you run undo.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Qt 5.4 being pretty outdated, did you check whether you still have the same behaviour with 5.12 or the current 5.13 preview ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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