QFile file (" E: \ \ QtProject Tree \ \ \ \ manager. TXT ");
QTextCodec * codec=QTextCodec: : codecForName (" GBK ");
If (file. Open (QIODevice: : ReadWrite))
{qDebug () & lt; <" File can be opened successfully ";
int i=0;
while(! The file, atEnd () & amp; & i<19)
{
QByteArray line=file. ReadLine ();
QString STR (line);
The manage [I]=STR;
i++;
QDebug () & lt; <" "Read elements & lt; & lt; i<& lt; The manage [I];
}
File. The close ();
}
QDebug () & lt; <" Read the success ";
}
The manage is a QString [] array (don't know can use)
Why this code display file is opened, the console output is the blank space
CodePudding user response:
QString array can consider to use QStringList (also seemed QListCodePudding user response:
Usually we use QStringList or QVectorQString manager [16]. This also please defined as QString * manager [16]. At the time of actual use
QString STR=new QString (line);
The manage [I]=STR;
Don't forget to delete after use
CodePudding user response:
Way as to why not directly in c array, in simple terms: array for storage of thing is a thing (f), a QString variable-length calculate is the actual contentCodePudding user response:
Since using QT and c + +, that is proposed to train of thought transformation to object-oriented,As the second floor, use QStringList can, don't use it, please consult the help manual,
I wish you a speedy skilled use of Qt
CodePudding user response:
Use QVector