How to detect mouse over event when mouse over icon on item delegate



  • i have item delegate and im doing mouse tracking there , i can only do mouse tracking when i click with the mouse and then i check region of the mouse in the item space.
    but i like to be able to catch the event when mouse is over icon, how can i do it from the model?
    this is the code i have to track the mouse press:
    @bool PlayListMiniItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
    const QStyleOptionViewItem &option,
    const QModelIndex &index)
    {
    // Emit a signal when the icon is clicked
    if(!index.parent().isValid() &&
    event->type() == QEvent::MouseButtonRelease) {

    QMouseEvent mouseEvent = static_cast<QMouseEvent>(event);

    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()))
            {
                
     
     
    emit closeButtonRectIndexClicked(index);
     
            }
    

    else if(iconRemoveRect.contains(mouseEvent->pos()))
    {

    emit iconRemoveRectIndexClicked(index);
    

    }
    }
    return false;
    }@


Log in to reply
 

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