Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I need help for build an open source project, please.
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 470 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ronaldon
    wrote on 22 Jan 2021, 22:44 last edited by
    #1

    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&)'
    MainWindow::loadFile(fileName);
    ^

    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)"));

    if(!fileName.isEmpty()){
        QFile file(fileName);
        if (!file.open(QIODevice::ReadOnly)) {
            QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
            return;
        }
        qDebug() << "Open:"  + fileName;
        //MainWindow::loadFile(fileName);
        MainWindow::loadFile(fileName);
    }
    

    }

    K A J 3 Replies Last reply 23 Jan 2021, 02:43
    0
    • R ronaldon
      22 Jan 2021, 22:44

      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&)'
      MainWindow::loadFile(fileName);
      ^

      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)"));

      if(!fileName.isEmpty()){
          QFile file(fileName);
          if (!file.open(QIODevice::ReadOnly)) {
              QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
              return;
          }
          qDebug() << "Open:"  + fileName;
          //MainWindow::loadFile(fileName);
          MainWindow::loadFile(fileName);
      }
      

      }

      K Offline
      K Offline
      Kent-Dorfman
      wrote on 23 Jan 2021, 02:43 last edited by
      #2

      @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?

      1 Reply Last reply
      2
      • R ronaldon
        22 Jan 2021, 22:44

        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&)'
        MainWindow::loadFile(fileName);
        ^

        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)"));

        if(!fileName.isEmpty()){
            QFile file(fileName);
            if (!file.open(QIODevice::ReadOnly)) {
                QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
                return;
            }
            qDebug() << "Open:"  + fileName;
            //MainWindow::loadFile(fileName);
            MainWindow::loadFile(fileName);
        }
        

        }

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 23 Jan 2021, 05:57 last edited by
        #3

        @ronaldon

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

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        2
        • C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 23 Jan 2021, 08:57 last edited by
          #4

          https://stackoverflow.com/questions/65854304/how-to-solve-the-error-use-of-deleted-function-qfileqfileconst-qfile-on-q

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          2
          • R ronaldon
            22 Jan 2021, 22:44

            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&)'
            MainWindow::loadFile(fileName);
            ^

            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)"));

            if(!fileName.isEmpty()){
                QFile file(fileName);
                if (!file.open(QIODevice::ReadOnly)) {
                    QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
                    return;
                }
                qDebug() << "Open:"  + fileName;
                //MainWindow::loadFile(fileName);
                MainWindow::loadFile(fileName);
            }
            

            }

            J Online
            J Online
            JonB
            wrote on 23 Jan 2021, 09:00 last edited by JonB
            #5

            @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....

            1 Reply Last reply
            3
            • R Offline
              R Offline
              ronaldon
              wrote on 27 Feb 2021, 16:14 last edited by
              #6

              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!!!

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved