I'm newbie and using qt creator. I want to make loop to read until 11th line from beginning of my text file.
After read read until 11th line of text file, i want to the double spin box value to 11th line.
My code does not work well. If explain just like use QTextStream, then i cannot understand. I'm newbie.
Can anyone know? and explain detail to newbie?
My text file is large, and qt version is 5.13
void MainWindow::on_doubleSpinBox_6_editingFinished()
{
QString file("D:\\my text file name");
{
int i=0;
while (true)
{
if(i==10)
{
file = stream.readLine();
stream <<
QString::number(ui
->doubleSpinBox_6
->value
());
break;
}
else
{
i=i+1;
}
}
}
outputFile.close();
void MainWindow::on_doubleSpinBox_6_editingFinished()
{
QString file("D:\\my text file name");
QFile outputFile(file);
if (outputFile.open(QIODevice::ReadWrite | QIODevice::Text))
{
int i=0;
while (true)
{
if(i==10)
{
QTextStream stream(&outputFile);
file = stream.readLine();
stream << QString::number(ui->doubleSpinBox_6->value());
break;
}
else
{
i=i+1;
}
}
}
outputFile.close();
To copy to clipboard, switch view to plain text mode
Bookmarks