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. Mouse Cursor reset problem
Forum Updated to NodeBB v4.3 + New Features

Mouse Cursor reset problem

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.9k 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.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    i have item delegate that when the mouse event is over icon i change its Cursor to Qt::PointingHandCursor
    when its off i set it back to Qt::ArrowCursor . its working fine .
    the problem is that besides when it over the icon . it allways stack on Qt::ArrowCursor
    even in situation when the icon needs to changes nativly like when resizing the windows or when over native push button . it always Qt::ArrowCursor.
    how can i force the Cursor act normally when its is no over the icon?
    here is what i do :
    @
    bool MiniItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
    const QStyleOptionViewItem &option,
    const QModelIndex &index)
    {
    // Emit a signal when the icon is clicked
    QMouseEvent mouseEvent = static_cast<QMouseEvent>(event);
    if(!index.parent().isValid() && event->type() == QEvent::MouseMove)
    {
    QSize iconsize = m_iconAdd.actualSize(option.decorationSize);
    QRect closeButtonRect = m_iconAdd.pixmap(iconsize.width(),iconsize.height())
    .rect().translated(AddIconPos(option));

        QSize iconRemoveSize = m_iconRemove.actualSize(option.decorationSize);
        QRect iconRemoveRect =  
                m_iconRemove.pixmap(iconRemoveSize.width(), iconRemoveSize.height())
                        .rect().translated(RemoveIconPos(option));
     
        if(closeButtonRect.contains(mouseEvent->pos()))
        {                
            QApplication::setOverrideCursor(QCursor(Qt::PointingHandCursor)); 
        }
        else if(iconRemoveRect.contains(mouseEvent->pos()))
        {
            QApplication::setOverrideCursor(QCursor(Qt::PointingHandCursor)); 
        }
        else
        {
            Qt::CursorShape shape = Qt::ArrowCursor;
            QApplication::setOverrideCursor(QCursor(shape)); 
        }
    }
    
    if(!index.parent().isValid() && event->type() == QEvent::MouseButtonRelease) 
    {
        QSize  iconsize = m_iconAdd.actualSize(option.decorationSize); 
        QRect closeButtonRect =  m_iconAdd.pixmap(iconsize.width(),iconsize.height())
                .rect().translated(AddIconPos(option));
    
        QSize iconRemoveSize = m_iconRemove.actualSize(option.decorationSize);
        QRect iconRemoveRect =  
                m_iconRemove.pixmap(iconRemoveSize.width(),iconRemoveSize.height())
                        .rect().translated(RemoveIconPos(option));
    
        if(closeButtonRect.contains(mouseEvent->pos()))
        {
            ; 
        }
        else if(iconRemoveRect.contains(mouseEvent->pos()))
        {
            ; 
        }
    }
    
    return false;
    

    }
    @

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dridk
      wrote on last edited by
      #2

      Which widget are you using with your delegate ?

      Nothing in Biology Makes Sense Except in the Light of Evolution

      1 Reply Last reply
      0
      • U Offline
        U Offline
        umen242
        wrote on last edited by
        #3

        QStyledItemDelegate with QTableView

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dridk
          wrote on last edited by
          #4

          I mean widgets for cell editing.
          Could you make a screenshot ?

          Nothing in Biology Makes Sense Except in the Light of Evolution

          1 Reply Last reply
          0
          • U Offline
            U Offline
            umen242
            wrote on last edited by
            #5

            what widgets ? i dont understand
            im using simple icon images

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on last edited by
              #6

              You're probably looking for "restoreOverrideCursor":/doc/qt-4.8/qapplication.html#restoreOverrideCursor to undo the effects of setOverrideCursor.

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              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