Answer the question
In order to leave comments, you need to log in
Why doesn't reading and writing to files work in qt creator?
There is a window, in the window there is a button and a label. button code
void HelloWindow::on_pushButton_clicked()
{
QFile fileOut("data.txt");
QString name=ui->pushButton->text();
if(fileOut.open(QFile::ReadOnly | QFile::Text)){
QTextStream stream(&fileOut);
QString str=stream.readAll();
ui->label->setText(str);
}
else
QMessageBox::information(this,"error","ERROR!");
fileOut.close();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question