Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable editing in QSpinbox but enable arrows

Tags:

pyqt

I have a QSpinBox in which I want to enable the arrows (for up and down values) but disable inserting data by the user. I've tried using this:

QtGui.QSpinBox.setReadOnly(True)

But it doesn't work. All is disabled and the arrows are 'stuck'.

like image 675
roy.me Avatar asked Sep 08 '16 13:09

roy.me


1 Answers

If you set the spin-box readonly, it will disable eveything. Instead, just set the line-edit readonly, and then buttons will still work:

spinbox.lineEdit().setReadOnly(True)
like image 69
ekhumoro Avatar answered Sep 29 '22 00:09

ekhumoro