Custom Delegate for QTableView in QCompleter not invoked
Hello,
i have a QLineEdit with a QCompleter which is used as a search bar. The customer now wants an icon to be displayed at the end of each completer row, but only when the entry is highlighted or when the mouse is hovering over it.
I tried to achieve this by overriding the paint method of a custom delegate derived from QStyledItemDelegate, as I have done it before with a QTreeView.
I basically duplicated the procedure for installing the delegate but the overridden methods dont get invoked at all.
Code:
ptrDelegate = new SearchBarDelegate();
ptrView->verticalHeader()->setVisible(false);
ptrView->horizontalHeader()->setVisible(false);
ptrView
->setSelectionBehavior
(QTableView::SelectRows);
ptrView->setShowGrid(false);
ptrView->setItemDelegate(ptrDelegate);
ptrCompleter->setCompletionColumn(0);
ptrCompleter
->setCompletionMode
(QCompleter::UnfilteredPopupCompletion);
ptrCompleter->setCaseSensitivity(Qt::CaseInsensitive);
ptrCompleter->setMaxVisibleItems(amountSearchRecommendations);
ptrCompleter->setPopup(ptrView);
setCompleter(ptrCompleter);
and the delegate class looks like this
Code:
class SearchBarDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
SearchBarDelegate
(QWidget *parent
= Q_NULLPTR
) : { }
};
I tried to subclass it from QItemDelegate, QAbstractItemDelegate but to no avail.
thx in advance