hello qt experts,
i am a beginner in qt.. i am developing a simple application and in that i have a line edit in dialog...and i want to create text file and wrote the lineedit input to that text file..please help me...
hello qt experts,
i am a beginner in qt.. i am developing a simple application and in that i have a line edit in dialog...and i want to create text file and wrote the lineedit input to that text file..please help me...
Have a look at QFile for handling the actual I/O and QTextStream for writing the QString from the line edit into the file.
Cheers,
_
prasad1001 (5th February 2014)
Thanks for the quick reply, actually my code is...
void New:n_pushButton_clicked()
{
QString fileName1=ui->lineEdit->text();
qDebug()<<fileName1;
QFile file(fileName1);
if(file.open(QIODevice::WriteOnly))
{
QTextStream stream(&file);
stream<< "Employ Name:"<<(ui->lineEdit->text()) <<"\n"<<"Employ ID:"<<(ui->lineEdit_2->text());
stream.flush();
file.close();
}
//exit(1);
close();
}
Actually the files are creating in my project folder...but how to save those files in a specific folder....
Thank in advance..
If you set file name by
The file will be created in the current working directory - in the project directory unless you have changed CWD.
The file name can contain a directory, for example:
The file will be created in /home/me/here .Qt Code:
To copy to clipboard, switch view to plain text mode
For example:
Qt Code:
QFile file; if( fileName1.contains('/') ) file.setFileName(fileName1); // if fileName1 contains a directory else file.setFileName(defDir + fileName1); //else set default directory if( file.open( ... ) ) { ...To copy to clipboard, switch view to plain text mode
Thanks for the quick reply...
I have other issue...i.e...i want to wait until i get input form lineEdit to match with other string..please help me...
Connect to the line edit's editingFinished() signal and perform the check in that slot.
Cheers,
_
prasad1001 (5th February 2014)
Hello Qt Experts,
i want to use my lineEdit for the login form ....so how do I make the QLineEdit widget mask the text in it with circles or asterisks for password entry and how i get the entered text to a Qstring?
Thanks in Advance...
First of all : start reading the Qt manual.
Bookmarks