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 detect mouse over event when mouse over icon on item delegate
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 3.3k 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 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;
    }@

    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