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. Qt::TextFlag vs. QTextOption
Forum Updated to NodeBB v4.3 + New Features

Qt::TextFlag vs. QTextOption

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.4k 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    I am slightly confused about the use of Qt::TextFlag versus QTextOption.

    I am preparing a QStaticText, that can either be single line or multi line.

    QStaticText::size() is unreliable in certain circumstances (so far, it returns incorrect results on a Windows 7 machine, with the font size given in Pixels, not Point).

    Therefore, I am trying to calculate the size using good old QFontMetrics.

    Now, QStaticText uses the QTextOption object, so I have a QTextOption object ready for use.
    However, QFontMetrics wants Qt::TextFlag.

    Is there a way to translate one to the other, or do I have to do it by hand (as far as the flags match at all)?

    1 Reply Last reply
    0
    • BilbonSacquetB Offline
      BilbonSacquetB Offline
      BilbonSacquet
      wrote on last edited by
      #2

      The big difference between both approach is the technology used:
      QStaticText use internally a QTextDocument to layout, so mainly the interface need a QTextCharFormat and a QTextOption to format the text (mainly rich text).
      In the case of the font based fonction like, drawText() or QFontMetrics class they are using a simplier layout mechanism, which needs just the align and QTextFormat (mainly single font).
      Mainly it's 2 differents approachs to render the text.

      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