Validating user input in a QTableView
问题 I have a QTableView and I want to validate user input. If user insert an invalid value in a cell of the QTableView , I want to highlight that cell and disable a QPushButton . How can I achieve this? Can I use QValidator ? 回答1: Yes, you can do this, use custom QItemDelegate for this purpose (I used QIntValidator just as example). Header: #ifndef ITEMDELEGATE_H #define ITEMDELEGATE_H #include <QItemDelegate> class ItemDelegate : public QItemDelegate { Q_OBJECT public: explicit ItemDelegate