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 move QGraphicsTextItem's text along with cursor.
Qt 6.11 is out! See what's new in the release blog

How to move QGraphicsTextItem's text along with cursor.

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

    How to make a QGraphicsTextItem, having constant width, to follow its cursor when the text is wider than the width of the QGraphicsTextItem?

    1. If you just create a QGraphicsTextItem and start typing text, the text item is resized to fit the text e.g. becomes wider.
    2. If you set the QGraphicsTextItem text width through setTextWidth to be > 0, then you'll get a text wrapping - the text item becomes multi-line.
    3. Subclass QGraphicsTextItem and override its boundingRect method. Return the boundingRect() calculated by the base class (QGraphicsTextItem) but set the width to a constant value before that. Now you get the behaviour of 2) without being multi-line plus the fact that the text item's viewable area doesn't follow the cursor when the text is wider than the text item.

    Please, offer a Graphics Framework class that has the same behaviour as that of QLineEdit.
    Also, make note of: https://bugreports.qt.nokia.com/browse/QTBUG-21783

    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