PDA

View Full Version : Transferring data input from a Widget to a cpp file



Ahmad
10th March 2007, 10:24
hi everyone, :)
i m new to QT Programming, and i must create an interface in which a user inputs his question in a LineEdit and the related responses in some LineEdit Widgets.
my probleme is that i dont know how to transfer those input datas that i get from LineEdits to a cpp file where then i can output those data in an external file.. pls help me

n the next step is to read that external file and put back the question a LineEdit Widget and the related responses in Some CheckBox Widgets..

pls help me, i dont know much QT data transfer..
tnx :( :confused:

jpn
10th March 2007, 10:59
Start with reading the detailed descriptions of QFile and QTextStream.

Here are a couple of examples picked out of the documentation (follow the links above):


// read
QFile file("in.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;

QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
process_line(line);
}

// write
QFile file("out.txt");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return;

QTextStream out(&file);
out << "The magic number is: " << 49 << "\n";