Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ Error in Qt: has initializer but incomplete type

Tags:

c++

qt

void FindWords::getTextFile() {
    QFile myFile(":/FindingWords2.txt");
    myFile.open(QIODevice::ReadOnly);

    QTextStream textStream(&myFile);
    QString line = textStream.readAll();
    myFile.close();

    ui->textEdit->setPlainText(line);
    QTextCursor textCursor = ui->textEdit->textCursor();
    textCursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1);
}

The QTextStream textStream(&myFile) keeps giving me the error and I can't fix it.

like image 856
user2487294 Avatar asked Jun 14 '13 19:06

user2487294


2 Answers

You forgot to include <QTextStream> or <QFile>.

like image 163
Tyler Jandreau Avatar answered Nov 03 '22 07:11

Tyler Jandreau


I added

#include <QTextStream>
#include <QFile>
#include <QDataStream>

and it worked for me.

like image 35
henry hache Avatar answered Nov 03 '22 06:11

henry hache