PDA

View Full Version : How can I read from Text Edit



sujan.dasmahapatra
12th October 2009, 10:26
Dear Friends
I have some values in Text Edit in the dialog box , the values are like below
2 0.323 0.3232
1st values is an ineteger and the rest two are doubles.

How can I read these values independently from Text Edit. !!

Any suggestion would be appreciated.

caduel
12th October 2009, 10:52
you can't. grab the (complete) text as a QString and parse it.
You can use QTextStream for reading the numbers.

QString text = edit->toPlainText();
QTextStream ts(&text, QIODevice::ReadOnly);
double f1, f2, f3;
ts >> f1 >> f2 >> f3;

HTH

sujan.dasmahapatra
12th October 2009, 15:42
would this reading be sequential reading ??

caduel
12th October 2009, 17:57
please rephrase that (or just try it out....)

sujan.dasmahapatra
13th October 2009, 15:58
Thanks Friends let me I am trying it...

ambang_10111
5th November 2009, 22:22
Hi, i have created a project(Gui project) and in the main.cpp file i have some sql queries that gets data from a remote sever liekt this;
if(!query.exec("SELECT..........")){
qDebug()<<"FAIL";
}
while(query.next()){
QString name = query.value(0).toString();
qDebug() << name;
}
it works well and i have the results printed out like "abdnsh"
Now in my .ui i have Text Edit. How can i append the sql reults to the Text Edit in my .ui?
I'm a beginner, please i will appreciate