[Qt-creator] Is there a Try and Catch method in QT

Nicolas Arnaud-Cormos nicolas.arnaud-cormos at kdab.com
Thu Jul 1 08:00:53 CEST 2010


On Thursday 01 July 2010 03:01:05 Diego Turcios wrote:
> Hi guys
> I thinks this is the right mailing list for my doubt.
> I am working on a small application in QT. But right now I have the
> following problem.
> I have a line edit, and I want to manipulate the values so only numbers
> (doubles) can be written on this line edit.

The right way to do this in Qt is to use a validator. Just write this line in 
the constructor of your dialog (after setting up the ui).
ui->LEPrecio->setValidator( new QDoubleValidator );

This way you are sure the user can only type a double. No need to do any 
check.

Nicolas

-- 
Nicolas Arnaud-Cormos | nicolas.arnaud-cormos at kdab.com | Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions




More information about the Qt-creator-old mailing list