user2487294
user2487294

Reputation: 127

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

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.

Upvotes: 11

Views: 23824

Answers (2)

henry hache
henry hache

Reputation: 31

I added

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

and it worked for me.

Upvotes: 3

Tyler Jandreau
Tyler Jandreau

Reputation: 4335

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

Upvotes: 27

Related Questions