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. WordWrap QGraphicsSimpleTextItem

WordWrap QGraphicsSimpleTextItem

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.0k Views
  • 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.
  • S Offline
    S Offline
    samdol
    wrote on last edited by
    #1

    I created a QGraphicsSimpleTextItem on my pixmapItem and set a text.
    If the text is short it is OK. but if the text is bigger than the pixmapItem width, I could not read the last part of the text.
    QGraphicsSimpleTextItem* simpleText==new QGraphicsSimpleTextItem(pixmapItem);
    fileInfo_simpleText->setText("This is long list. This is long list.");

    I was trying to find a method something like
    fileInfo_simpleText->wrap(QRect);
    But it seems not exist.
    How can I wordwrap my QGraphicsSimpleTextItem in a given QRect?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! IIRC you can get automatic word wrapping by replacing your QGraphicsSimpleTextItem with a QGraphicsTextItem.

      S 1 Reply Last reply
      1
      • ? A Former User

        Hi! IIRC you can get automatic word wrapping by replacing your QGraphicsSimpleTextItem with a QGraphicsTextItem.

        S Offline
        S Offline
        samdol
        wrote on last edited by
        #3

        @Wieland
        Thank you for the answer. QGraphicsTextItem could wrap the text as I expected. One minor concern is that when I set width, I had to do textItem->setTextWidth(geometry().width()*5.0/6) to fit the scene width. I have no idea why I have to muliply by 5/6 to fit.

        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