How to rotate a cursor for a QGraphicsItem



  • Hi
    I want to make a cursor icon rotate with my QGraphicsItem, I drew a box and other child items around my item and I want to show a Qt::SizeVerCursor when hovering over certain anchor points (the points are drawn as rectangles). This is so far working

    @
    void MyClass::hoverMoveEvent( QGraphicsSceneHoverEvent * event ){

    [...]
    if(m_childItems[ancors[i]]->boundingRect().contains( m_childItems[ancors[i]]->mapFromParent(event->pos()) )) {
    setCursor( Qt::SizeVerCursor );
    event->accept();
    return;
    }
    }
    @

    The only problem I am having is that when the item is rotated (for eg. 30°) I want the cursor to rotate by 30° too so that it reflects the following resize action to be along a major axis of the item. Right now the cursor is always vertical i i can't figure out anything to rotate the cursor. Google also didn't turn up anything useful.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The only way I see would be to create a QPixmap, update it yourself when needed and use it to create a QCursor to set.

    Hope it helps


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.