Well I have like 500 lines of text and i want it to show next line everytime i press next
class MainWindow { ... private: // member functions void MainWindow::initMyWordList(); private: // member variables static int _clickCounter; QStringList _wordList; };
in the first line of the file just after all the #includes define this variable, int MainWindow::_clickCounter = 0; and in MainWindow() { .... error = initMyWordList(); if ( error ) do whatever you feel like .... } //init my word file void MainWindow::initMyWordList() { QFile * wordFile = new QFile("/home/user/wordlist"); wordFile->open(QIODevice::ReadOnly); QTextStream stream(wordFile); // create the map of channel and date until which data is available while ( !stream.atEnd() ) { QString word = stream.readLine(); _wordList << word; } wordFile->close(); } void MainWindow::on_Button_clicked() { ui->label->setText(QString("the word of the day is %1").arg(_wordList[_clickCounter++]) ); }