gpt4 book ai didi

c++ - QFile::QFile 函数 --> 错误:QFile::QFile (const QFile &) 'is private

转载 作者:太空狗 更新时间:2023-10-29 23:37:08 26 4
gpt4 key购买 nike

在我的一个方法中,我需要一个 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)的。谁能告诉我如何解决这个问题?

最佳答案

替换:

QFile GEO = (loadedDirectory + "/1_geo.m4");

用这一行:

QFile GEO(loadedDirectory + "/1_geo.m4");

关于c++ - QFile::QFile 函数 --> 错误:QFile::QFile (const QFile &) 'is private,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9601821/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com