在我的方法中,我需要一个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!“标记的行。编译时,我得到错误信息:QFile ::QFile (const QFile &)‘是私有的。我不明白这一点,因为在QFile纪录片中,函数被声明为公共函数。有人能告诉我如何修复吗?
发布于 2012-03-07 12:52:17
取代:
QFile GEO = (loadedDirectory + "/1_geo.m4");用这一行:
QFile GEO(loadedDirectory + "/1_geo.m4");发布于 2012-03-07 12:53:13
你在这里做的事
QFile GEO = (loadedDirectory + "/1_geo.m4");使用赋值运算符从路径创建QFile,这是不可能的。
您应该像这样使用构造函数
QFile GEO(loadedDirectory + "/1_geo.m4");发布于 2012-03-07 12:52:33
删除等号以直接初始化.
https://stackoverflow.com/questions/9601821
复制相似问题