Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Put limits with pixels[SOLVED]
Forum Updated to NodeBB v4.3 + New Features

Put limits with pixels[SOLVED]

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 3 Posters 2.2k 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.
  • F Offline
    F Offline
    felipe.c.sousa
    wrote on last edited by
    #1

    I am, using html in Qt, and i want put limits in my strings for pixels, i use "mid" but the letters have diferent size, so not work very well.

    sorry for my english. =)

    From all, to all.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      @QFontMetrics fm(theFontYoureUsing);
      QString originalText("very long phrase that might not fit inside the parent window, how sad.");
      QString outText = fm.elidedText(originalText, Qt::ElideRight, 200)@

      the 200 is the maximum width of the text. For example, outText might contain:
      "very long phrase that might not fit insi..."

      1 Reply Last reply
      0
      • F Offline
        F Offline
        felipe.c.sousa
        wrote on last edited by
        #3

        i can not include "QFontMetric". Its need a new version to use that? My Qt is the 4.7.4.

        From all, to all.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          [[doc:QFontMetrics]] (note the 's'!) has been around for a very long time, at least since the 3.x days. So, it is there in your 4.7 version of Qt.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            felipe.c.sousa
            wrote on last edited by
            #5

            hehehe now i can include, i was write the rigth name, but i was drop the "gui".

            From all, to all.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              felipe.c.sousa
              wrote on last edited by
              #6

              thanks, is exactly what i want.

              From all, to all.

              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