Important: Please read the Qt Code of Conduct -

I need help for build an open source project, please.

  • stacktrace:
    D:\WORKSPACES\Emmeth\src\qEmmeth\mainwindow.cpp:80: error: use of deleted function 'QFile::QFile(const QFile&)'
    ..\qEmmeth\mainwindow.cpp: In member function 'void MainWindow::open()':
    ..\qEmmeth\mainwindow.cpp:80:38: error: use of deleted function 'QFile::QFile(const QFile&)'

    Error Session:
    void MainWindow::open()
    QString fileName = QFileDialog::getOpenFileName(this, tr("Load file"), "../../", tr("Emmeth Files (.emt);; XML Files (.xml);; PDF Files (.pdf);; TXT Files (.txt)"));

        QFile file(fileName);
        if (! {
            QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
        qDebug() << "Open:"  + fileName;


  • @ronaldon so which line is line 80? Seems it is the copy constructor for QFile Does a copy constructor for QFile even exist in the framework?

  • Lifetime Qt Champion


    fileName is a QString, not a QFile. What does the loadFile function require, can you show the function?


  • Lifetime Qt Champion

  • @ronaldon

    • filename is of type QString.
    • MainWindow::loadFile(QFile fileName) is the signature [from your stackoverflow post, thanks to @Christian-Ehrlicher, where unlike here you give the necessary information], so accepts a QFile, with an unhelpfully-named formal parameter. [Furthermore, this is passing-by-value-copy, which is not allowed for QFile as it is derived from QObject.]
    • So MainWindow::loadFile(fileName); is not going to work.

    What else is there to say?

    Also, it's not very fair to those who try to answer here that you post the same question, with more detail, on stackoverflow, do not reference that here, say there that you have your answer, and leave this question here still open....

  • Yes, thanks guys. I have seen the error like you say. It was a conflict of params ( QString and QFile ) in the function. Thank all of you!!!

Log in to reply