diff --git a/widgets/actionitemdelegate.cpp b/widgets/actionitemdelegate.cpp index 2464b93cc..2ac1506d0 100644 --- a/widgets/actionitemdelegate.cpp +++ b/widgets/actionitemdelegate.cpp @@ -190,6 +190,11 @@ bool ActionItemDelegate::helpEvent(QHelpEvent *e, QAbstractItemView *view, const QAction * ActionItemDelegate::getAction(const QModelIndex &index) const { + QList actions=index.data(ItemView::Role_Actions).value >(); + if (actions.isEmpty()) { + return 0; + } + QAbstractItemView *view=(QAbstractItemView *)parent(); bool rtl = Qt::RightToLeft==QApplication::layoutDirection(); QListView *lv=qobject_cast(view); @@ -215,11 +220,11 @@ QAction * ActionItemDelegate::getAction(const QModelIndex &index) const QRect actionRect=calcActionRect(rtl, actionPos, rect); QRect actionRect2(actionRect); ActionItemDelegate::adjustActionRect(rtl, actionPos, actionRect2, iconSize); - QList actions=index.data(ItemView::Role_Actions).value >(); + QPoint cursorPos=QCursor::pos(); foreach (const QPointer &a, actions) { actionRect=actionPos ? actionRect.adjusted(0, -2, 0, 2) : actionRect.adjusted(-2, 0, 2, 0); - if (actionRect.contains(QCursor::pos())) { + if (actionRect.contains(cursorPos)) { return a; }