I have a QTableView that populates files and folders as items using QAbstractTableModel
, I didn't used QFileSystemModel
because the table view doesnt solely displays folder names, it also displays attribute of files within the folder.
So my question is how do I add a validator on DisplayRole
or if someone tries to edit the folder name in the EditRole
, so that if the model loads the data and displays it should mark folder names with special character or those folder names with more than expected characters the cell containing the folder name should get red background ,
I have tried by adding a validator that raises exception , so if it is fine BackgroundColorRole
returns QVariant
else in case of exception it returns QtCore.Qt.red