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 the correct size from QStaticText

How to get the correct size from QStaticText

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.0k 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 have a QStaticText that gets drawn using painter->drawStaticText.
    I call prepare() on the StaticText whenever I change text, font or alignment.

    Before I draw, however, I need to use the size() method of QStaticText, in order to calculate the correct position.
    Since I called prepare(), it should contain the correct size already.

    Usually it does. But on some computers, the text "jumps", because the size of the staticText changes, although none of the input parameters I control has changed.

    Unfortunately, it is only updated in drawStaticText - too late to be taken into account by me.

    Is there any method of QStaticText I could call to check whether the text needs to be updated, so that I can get a correct size before drawing?

    Addendum:

    I now also compare the transformation I used on prepare() versus the painter's world transformation, and manually call prepare when they are not equal.

    No change.

    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