[Qt-interest] How do I turn-off/hide the text cursor in QSpinBox?
Atlant Schmidt
aschmidt at dekaresearch.com
Mon Apr 4 17:44:33 CEST 2011
All:
Thanks for all the help, everyone!
As it turns out, to work-around various other
limitations in the Q(Abstract)SpinBox implementation
when it's used on touch-screens, we already did have
QSpinBox subclassed and had already been assigning
a new QLineEdit to the subclass.
So by Friday afternoon, I was doing exactly what has
been suggested and attempting to set just the QLineEdit
to "Read Only". Done in the QSpinBox constructor (after
we've done the setLineEdit() to substitute our own
QLineEdit instance), this didn't work; some initialization
farther down the road clears the Read-Only status.
Today, I took a big hammer and simply re-asserted the
Read-Only status with every step taken by the spin-box:
lineEdit()->setReadOnly(true);
That works.
But when I look at all the work we've done to make
spin boxes work for us (in our touch screen environment),
I'm pretty sure we'd have been better-off if we hadn't
used Q(Abstract)SpinBox at all and simply used two of
our "Sound-making pushbuttons" and a QLabel to display
the results.
There really needs to be a simple class for Spinboxes
on touchscreens that doesn't carry all the burdens of
this QLineEdit-based class.
Atlant
-----Original Message-----
From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Bo Thorsen
Sent: Friday, April 01, 2011 02:12
To: Sean Harmer
Cc: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] How do I turn-off/hide the text cursor in QSpinBox?
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
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
Thank you.
Please consider the environment before printing this email.
More information about the Qt-interest-old
mailing list