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 questions
Qt 6.11 is out! See what's new in the release blog

QTextEdit questions

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 585 Views 2 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1
    1. Is it possible to ask the text edit control to use a slightly tighter line spacing?

    2. Is there any simple way to append text without adding a new line?

    Thanks, David

    JonBJ 1 Reply Last reply
    0
    • PerdrixP Perdrix
      1. Is it possible to ask the text edit control to use a slightly tighter line spacing?

      2. Is there any simple way to append text without adding a new line?

      Thanks, David

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Perdrix said in QTextEdit questions:

      Is it possible to ask the text edit control to use a slightly tighter line spacing?

      Many examples from Google qtextedit set line spacing, such as https://stackoverflow.com/questions/10250533/set-line-spacing-in-qtextedit ?

      Is there any simple way to append text without adding a new line?

      Since QTextEdit::append() "Appends a new paragraph" I would guess you need to use a QTextCursor to do something like insert text at the end of the existing last paragraph?

      PerdrixP 1 Reply Last reply
      0
      • JonBJ JonB

        @Perdrix said in QTextEdit questions:

        Is it possible to ask the text edit control to use a slightly tighter line spacing?

        Many examples from Google qtextedit set line spacing, such as https://stackoverflow.com/questions/10250533/set-line-spacing-in-qtextedit ?

        Is there any simple way to append text without adding a new line?

        Since QTextEdit::append() "Appends a new paragraph" I would guess you need to use a QTextCursor to do something like insert text at the end of the existing last paragraph?

        PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by Perdrix
        #3

        @JonB Thanks for the pointer

        Here's what I did for the spacing etc.

        //
        // Before any messages are written to the log, reduce the line spacing a bit
        // and reduce the font size by one
        //
        QTextBlockFormat bf = messageLog->textCursor().blockFormat();
        bf.setLineHeight(85, QTextBlockFormat::ProportionalHeight);
        messageLog->textCursor().setBlockFormat(bf);
        QFont font{ messageLog->currentFont() };
        font.setPointSize(font.pointSize() - 1); font.setWeight(QFont::Medium);
        messageLog->setFont(font);
        

        and for appending:

        messageLog->moveCursor(QTextCursor::End);
        messageLog->insertPlainText(message);
        
        1 Reply Last reply
        2

        • Login

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