QFile :: QFile函数->错误:QFile :: QFile(const QFile&)'是私有的 [英] QFile::QFile function --> Error: QFile :: QFile (const QFile &) 'is private

查看:615
本文介绍了QFile :: QFile函数->错误:QFile :: QFile(const QFile&)'是私有的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一种方法中,我需要一个QFile对象:

In one of my methods I need a QFile Object:

    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纪录片中,该函数被声明为public. 有人可以告诉我如何解决这个问题吗?

The problem is the line I marked with "// ERROR LINE HERE!". When compiling I get the error message: QFile :: QFile (const QFile &) 'is private. I don't understand this, because in the QFile documentary the function is declared as public. Can someone tell me how to fix that?

推荐答案

替换:

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

有这行:

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

这篇关于QFile :: QFile函数->错误:QFile :: QFile(const QFile&)'是私有的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆