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 rotate a cursor for a QGraphicsItem

How to rotate a cursor for a QGraphicsItem

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

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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