在我的方法之一,我需要一个QFile对象:一个QFile ::一个QFile功能 - >错误:一个QFile :: QFile时(常量一个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)
{
...
}
}
的问题是标志着我行与“// 错误行在这里!”。编译时,我收到错误消息:QFile :: QFile(const QFile &)'是私人的。我不明白这一点,因为在QFile记录片中,该函数被声明为公共的。 有人可以告诉我如何解决这个问题吗?
QFile时创建一个QFile是QObject,甚至不会复制一个QObject。这是Qt限制。使用operator =在堆上分配QObject是被禁止的 – 2012-03-12 08:27:22