How to limit the text entered in any cell of a QTableView to one character?
I'm trying to do a crossword game using QT. I'm using QTableView for this and It should be that the user can enter one and only one letter in any of the editable cells in the QTableView. The problem is that 开发者_运维技巧I cannot seem to figure out how to put limits or restrictions on what the user can enter in each editable cell. How to do it? I have looked at QT documentation, searched online, looked in key/mouse events in QT but still I did not get how to do it. Any help well be appreciated. Thank you.
I suggest you try a custom delegate. To get you started take a look at:
- Spin Box Delegate Example
- Star Delegate Example
The Star Delegate might be good one for you to start with. The idea is then you can do nice painting and handle the keypress.
精彩评论