开发者

QTableWidget, allow to type numbers only

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 sho开发者_开发知识库uld 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 using setValidator(). I believe the classes QIntValidator and QDoubleValidator will be perfect in this situation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜