I make a program that reads a file. I have a combobox that reads lines numbers: 1,6,11,..etc. I want to e.g. read lines 1-5 when line number 1 is choosen in combobox and push button is clicked (or read lines 6-10 when line 6 is choosen, end so on). For now I have this.
int line_counter=1;
if(file.open (QIODevice::ReadOnly | QIODevice::Text))
{
while(!stream.atEnd())
{
line = stream.readLine ();
if(!line.isNull ())
{
if((line_counter%5)==1)
ui->comboBox->addItem (line);
line_counter++;
}
}
}
stream.flush ();
file.close ();
void Servers::on_pushButton_clicked()
{
if(file.open (QIODevice::ReadOnly | QIODevice::Text))
{
for(int i=line_counter;i<line_counter+5;i++)
{
ui->textBrowser->setText(stream.readLine(i));
}
}
file.close ();
}