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. Rotating a QLabel

Rotating a QLabel

Scheduled Pinned Locked Moved General and Desktop
qimageqwidgetrotationscaleqgraphicsitem
3 Posts 3 Posters 4.1k 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
    sunil.nair
    wrote on 30 Nov 2016, 15:27 last edited by
    #1

    Hi, I have a QImage as QGraphicsItem in my QGraphicsView. I am resizing and rotating the image using setTransform.

    QTransform rot;
    rot.translate(x,x);
    rot.rotate(45);
    rot.translate(-x,-x);
    graphicsItem->setTransform(rot);
    

    Now I want to put a Qframe/Qlabel on top of this image which acts as a frame. I want the frame(widget) to rotate and resize with this QGraphicsItem. How can I do it?

    R 1 Reply Last reply 30 Nov 2016, 15:31
    0
    • S sunil.nair
      30 Nov 2016, 15:27

      Hi, I have a QImage as QGraphicsItem in my QGraphicsView. I am resizing and rotating the image using setTransform.

      QTransform rot;
      rot.translate(x,x);
      rot.rotate(45);
      rot.translate(-x,-x);
      graphicsItem->setTransform(rot);
      

      Now I want to put a Qframe/Qlabel on top of this image which acts as a frame. I want the frame(widget) to rotate and resize with this QGraphicsItem. How can I do it?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 30 Nov 2016, 15:31 last edited by
      #2

      @sunil.nair
      why does it have to be a QWidget?
      Easiest would be if you can use QGraphicsRectitem/QGraphicsTextItem and place it as a child of the image item. Then it will be also rotated along with the image item.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on 30 Nov 2016, 17:29 last edited by
        #3

        You can add a widget to the scene using QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags = Qt::WindowFlags()).

        1 Reply Last reply
        0

        3/3

        30 Nov 2016, 17:29

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved