ShamusVW
20th November 2009, 06:44
I am trying to use a QTextStream object as a data member as follows:
[in .h file]
private:
QTextStream *out;
[in .cpp file]
QFile file(fileName);
if (!file.open(QIODevice::Append | QIODevice::Text))
return;
out = new QTextStream(&file);
out << "test";
...
but it has a compile time error
error: invalid operands of types `QTextStream*' and `const char[5]' to binary `operator<<'
I then modified it to
QTextStream o(&file);
out = &o;
out << "test";
but still the same error.
Can someone please tell me the correct way to do this?
[in .h file]
private:
QTextStream *out;
[in .cpp file]
QFile file(fileName);
if (!file.open(QIODevice::Append | QIODevice::Text))
return;
out = new QTextStream(&file);
out << "test";
...
but it has a compile time error
error: invalid operands of types `QTextStream*' and `const char[5]' to binary `operator<<'
I then modified it to
QTextStream o(&file);
out = &o;
out << "test";
but still the same error.
Can someone please tell me the correct way to do this?