Here is is:
labeldelegate.h
class labelDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
...
...
};
class labelDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
...
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
...
};
To copy to clipboard, switch view to plain text mode
labeldelegate.cpp
{
if (event
->type
() == QEvent::MouseButtonDblClick) {
qDebug() << "TMouseButtonDblClick works fine";
return true;
}
if (event
->type
() == QEvent::Enter) //Does not work {
qDebug() << "Enter";
QCursor cursor
(Qt
::PointingHandCursor);
return true;
}
if (event
->type
() == QEvent::Leave) //Does not work. {
qDebug() << "Leave";
return true;
}
return false;
}
bool labelDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &, const QModelIndex &index)
{
if (event->type() == QEvent::MouseButtonDblClick)
{
qDebug() << "TMouseButtonDblClick works fine";
return true;
}
if (event->type() == QEvent::Enter) //Does not work
{
qDebug() << "Enter";
QCursor cursor(Qt::PointingHandCursor);
QApplication::setOverrideCursor(cursor);
return true;
}
if (event->type() == QEvent::Leave) //Does not work.
{
qDebug() << "Leave";
QCursor cursor(Qt::ArrowCursor);
QApplication::setOverrideCursor(cursor);
return true;
}
return false;
}
To copy to clipboard, switch view to plain text mode
Many thanks
Bookmarks