1

So i have a QFile and QTextStream member as part of my class... trying to init. them together in my constructor:

Class.h:

QFile _file;
QTextStream _textstrm;

Class.cpp:

_file = QFile (/*file name*/);
_file.open(/*set stuff*/);
_textstrm = QTextTream ( &_file );

And the comp error i get, C2248, says the objects to have access to the operators in their own class..

4

1 回答 1

2

问题是您正在创建一个新对象并且您正在添加一个无法访问的属性,您必须使用该对象提供的功能。

_file.setFileName(/*file name*/);
_file.open(/*set stuff*/);
_textstrm.setDevice( &_file );
于 2017-05-05T19:01:32.817 回答