在我的一种方法中,我需要一个 QFile 对象:
void GUIsubclassKuehniGUI::LoadDirectory()
{
QString loadedDirectory = QFileDialog::getExistingDirectory(this,
"/home",tr("Create Directory"),
QFileDialog::DontResolveSymlinks);
ui.PathDirectory -> setText(loadedDirectory);
QFileInfo GeoDat1 = loadedDirectory + "/1_geo.m4";
QFileInfo GeoDat2 = loadedDirectory + "/2_geo.m4";
QString Value;
if (GeoDat1.exists() == true)
{
QFile GEO = (loadedDirectory + "/1_geo.m4"); // ERROR LINE HERE!
if(GEO.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream Stream (&GEO);
QString Text;
do
{
Text = Stream.readLine();
QString startWith = "start";
QString endWith = "stop" ;
int start = Text.indexOf(startWith, 0, Qt::CaseInsensitive);
int end = Text.indexOf(endWith, Qt::CaseInsensitive);
if (start != -1)
Value = Text.mid(start + startWith.length(), end - ( start + startWith.length() ) );
double ValueNumber = Value.toDouble();
ValueNumber = ui.ValueLineEdit->value();
}
while(!Text.isNull());
GEO.close();
}
}
else if (GeoDat2.exists() == true)
{
...
}
}
问题是我用“// ERROR LINE HERE! ”标记的那一行。编译时我收到错误消息:QFile :: QFile (const QFile &) 'is private。我不明白这一点,因为在 QFile 纪录片中,该函数被声明为 public。有人可以告诉我如何解决吗?