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. Dimensions of characters

Dimensions of characters

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 5 Posters 525 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.
  • M Offline
    M Offline
    Martinuccia_96
    wrote on last edited by
    #1

    Hi everyone.
    I have a question referred to the built of characters. Is the character included in a rectangle depending on the size and not on the font? If yes, how can I save the dimensions of this rectangle?

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

      Hi,

      What rectangle ?
      What font ?
      What are you doing ?

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

      M 1 Reply Last reply
      0
      • L Offline
        L Offline
        LittleFire
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          What rectangle ?
          What font ?
          What are you doing ?

          M Offline
          M Offline
          Martinuccia_96
          wrote on last edited by
          #4

          @SGaist I try to explain better the problem.
          We want to place another visible cursor in qtextedit.
          For doing this we try to use labels, but we need to understand its right position on the y axis to put it in.
          If all letters have the same size, it isn't a problem, we can do it with QRect of function QtextEdit::cursorRect() and the cursor appears in the position that we want to.
          But when we switch from a larger size (i.e 72) to a smaller one (i.e 12) and we continue to write on the same line, we resize our cursor and now we don't have any reference to place it.
          So we think that maybe there can be a general rule for fonts (for example all characters of size 9 have to fit a specific rectangle of specific dimensions indipendently on the font) that we can use for doing some proportion and calculate the right position. And if this rectangle exist how can we take its dimensions having only the size of font.

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            Im not really sure what you are doing with those labels,
            but if its about font and a box around a string then
            https://doc.qt.io/qt-5/qfontmetrics.html#boundingRect
            can be used to get the rectangle for a given text string.

            1 Reply Last reply
            1

            • Login

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