[Qt-interest] How do I turn-off/hide the text cursor in QSpinBox?

Bo Thorsen bo at fioniasoftware.dk
Fri Apr 1 08:11:51 CEST 2011


Den 31-03-2011 23:16, Sean Harmer skrev:
> Hi,
>
> On 31/03/2011 20:53, Atlant Schmidt wrote:
>> Sean:
>>
>>     First thing I tried! ;-)
>>
>>     Unfortunately, that also makes the entire spin-box
>>     read-only; not only can't you edit the text of the
>>     value, you can't change it's value by pressing
>>     the buttons either.
>
> Hmmm, if you still want to be able to use the button to change the value
> but not the line edit (since you said it is purely a touch app) then one
> approach is to subclass QSpinBox and in the constructor of your
> subclass, use the protected QAbstractSpinBox::lineEdit() function to get
> a pointer to the line edit sub-control and then call setReadOnly( true )
> on that.

Or a bit simpler perhaps?

spinbox->findChildren<QLineEdit*>().at(0)->setReadOnly(true);

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk



More information about the Qt-interest-old mailing list