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. How to get QTextEdit Text minimum Height ? I Want use ScrollBar..
Forum Updated to NodeBB v4.3 + New Features

How to get QTextEdit Text minimum Height ? I Want use ScrollBar..

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 714 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
    #1

    Hello. I use windows 8.1 64bit and linux 64bit,
    I am using Qt Version 5.4.

    The text is written in QTextEdit and you can resize this TextEdit widget.

    When you resize the TextEdit widget while text is being written, a scrollbar is automatically created when the size is reduced.

    I want to know the minimum size of the text in the TextEdit Widget without scrollbars, and I can't make the widget smaller than its size.

    How can I find the minimum size without scrollbars?

    Example 1)

    ab
    c

    When written as above, the screen

    ab
    c

    This is the minimum size at which no scrollbars appear.

    Example 2)

    abc

    When I wrote as above, on a screen

    abc

    This is the minimum size at which no scrollbars appear.

    Thank you.

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

      Hi,

      QFontMetrics::boundingRect seems to be what you are looking for.

      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
      1
      • SGaistS SGaist

        Hi,

        QFontMetrics::boundingRect seems to be what you are looking for.

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

        @SGaist

        Even though each font has a different color and bold font size, can I solve it with plain text? It doesn't seem to work.

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

          What exactly does not work ?
          Note that Qt 5.4 is more than outdated, you should consider updating to a recent version.

          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

            What exactly does not work ?
            Note that Qt 5.4 is more than outdated, you should consider updating to a recent version.

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

            @SGaist

            https://forum.qt.io/topic/112598/how-to-get-fit-size/1

            I want to do it like the above article.

            Setting toPlainText returns a smaller size than desired
            The scroll bar is still visible.

            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