How to disable text selection in a QDoubleSpinBox?

102 Views Asked by At

I want to make (or at least know If this is even possible) text that appears in QDoubleSpinBox to be unselectable. Right now, it looks like this:

QDoubleSpinBBox with text highlighted

I have managed to make it so that the QDoubleSpinBox can't be focused with setFocusPolicy(Qt::NoFocus). But this doesn't apply to the text in it.

1

There are 1 best solutions below

1
Pamputt On

You can make the text unselectable by calling setEnabled(false). But it will disable the whole QWidget (disable keyboard and mouse events). So, you should be more precise about what you want to disable and what do you want to keep enabled.