From 10:00 CET Friday 22nd November we will adjust how the server works to deal with some recently reported problems. Therefore there may be a load problem, if you experience more problems than usual trying to access the forum then please PM AndyS or any of the moderators so they can inform me.


Rotating a QLabel



  • 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?


  • Moderators

    @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.



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