-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItemDelegate.h
35 lines (33 loc) · 1.04 KB
/
ItemDelegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef ITEMDELEGATE_H
#define ITEMDELEGATE_H
#include <QEvent>
#include <QStyledItemDelegate>
#include <QKeyEvent>
#include <QTableWidget>
#include <QToolTip>
#include <QDebug>
// itemdelegate.h
class ItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit ItemDelegate(QTableWidget *tableWidget,QObject *parent = nullptr) : QStyledItemDelegate(parent),qTableWidget{tableWidget}
{
}
bool eventFilter(QObject *object, QEvent *event) override
{
if (event->KeyPress == QEvent::KeyPress) {
// QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
// QTableWidgetItem* currentItem = qTableWidget->currentItem();
// if (currentItem) {
// QString typedText = currentItem->text();
// currentItem->setToolTip("Typed Text: " + typedText);
// QToolTip::showText(QCursor::pos(), currentItem->toolTip());
// }
}
return false;
}
private:
QTableWidget *qTableWidget;
};
#endif // ITEMDELEGATE_H