I have a QTableWidget
with four columns. I want the user to be able to insert only integers in the first three and a double in the fourth.
I believe that this can be done with delegate, but I have not found relevant examples (only some with QDateTimeEdit
).
What should I do?
Look at the documentation for
QItemDelegate
; it provides a pretty good description on how it can be used.Since with a delegate, you'll be able to provide your own custom editor, I would suggest that you use a
QLineEdit
with a validator set usingsetValidator()
. I believe the classesQIntValidator
andQDoubleValidator
will be perfect in this situation.