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
QLineEditwith a validator set usingsetValidator(). I believe the classesQIntValidatorandQDoubleValidatorwill be perfect in this situation.