Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    How to get the correct size from QStaticText

    General and Desktop
    1
    1
    1774
    Loading More Posts
    • 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
      Asperamanca last edited by

      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 Reply Quote 0
      • First post
        Last post