This is actually the Qt-creator mailing list, not the Qt mailing list. But
I'll answer your question anyway. In the future, though, ask Qt questions over
there. (It's called "qt-interest" and shows up if you search for that term.)
The QString::toDouble() method does not throw an exception if it gets text
that's not a double. Instead, it has the "ok" parameter to let you know that
information. See the documentation (inside Qt-creator!) for
QString::toDouble() to see how to use the ok parameter to do your test, instead
of try-catch.
But yes, the very fact that your code compiled tells you that C++ (and hence
Qt) support try-catch structures.
Nathan
On Jun 30, 2010, at 9:01 PM, 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.
I was trying something like this
double quantity;
try
{
quantity=ui->LEPrecio->text().toDouble();
}
catch(QString error)
{
QMessageBox msgBox;
msgBox.setText(error);
msgBox.exec();
}
After doing this. I am planning to manipulate the double value, but this
doesn't work. If I write hello world on the line edit. Supposly it converts it,
and it doesn't work. Any idea ;)
Diego Turcios
DiegoTc
Ubuntu User # 27518
-----------------------------------------------
Mis Blogs
http://diegoturcios.wordpress.com/
https://wiki.ubuntu.com/DiegoTurcios
----------------------------------------------------------
Recuerden Dios siempre esta presente:
http://sagradocorazondejesus-diegotc.blogspot.com/
<ATT00001..txt>
_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-creator