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. Runtime error when cancelling QFileDialog

Runtime error when cancelling QFileDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 1.3k 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.
  • M Offline
    M Offline
    mjgfm
    wrote on last edited by
    #1

    Good pm! I'm new to Qt Creator and can't seem to find a thread in any forum that is helpful for my issue. Whenever I cancel the QFileDialog::getOpenFileNames function, i get a runtime error "Invalid parameter passed to C runtime function." This happens when using both (X) button and cancel button. Error happens when the program runs the function and does not reach checking if QStringList is null/empty...Help would be greatly appreciated

    1 Reply Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by
      #2

      Hi,
      please show the code that you are speaking of.
      -Michael.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mjgfm
        wrote on last edited by
        #3

        QStringList fileNames;
        fileNames = QFileDialog::getOpenFileNames(this, "Select a file to open...","/home","Excel (*.xls)");

        1 Reply Last reply
        0
        • m.sueM Offline
          m.sueM Offline
          m.sue
          wrote on last edited by m.sue
          #4

          Hi,
          you are still a bit sparse on details.
          Does it happen in debug or release mode?
          Does it happen even when you run the program outside of QtCreator?
          Which OS?
          Which Qt version?
          Which QtCreator version?
          -Michael.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mjgfm
            wrote on last edited by
            #5

            It happens while running the code in Qt Creator. I have not tried creating an executable program so I can't say if it will happen outside Qt Creator.. but isn't that how it goes, if it happens in debug mode it will happen during exe run as well? OS is Windows 7. Qt Creator Version is 5.7.0. This is the error message
            0_1482398217006_upload-918dd5b9-ee7e-40e9-9bf9-1aa4caba4c5c

            m.sueM 1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              Your problem is almost surely not in the code you posted, could you show us what you do next with fileNames?

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              1
              • M Offline
                M Offline
                mjgfm
                wrote on last edited by
                #7

                there's a checking of whether or not the list is empty and the program should inform the user if it was cancelled. but it doesn't even reach the checking. i tried creating a messagebox before the checking just to see if fileNames was populated. it did not reach that part of the code either. From observation, the program crashes when QFileDialog::getOpenFileNames is being cancelled. I just don't know how I'm supposed to handle it. I can't even determine what the return value is because the system crashes first.

                if(fileNames.empty())// CHECKS IF NOT EMPTY OR CANCELLED
                {
                QMessageBox cancelled;
                cancelled.setWindowTitle("Failed File Selection");
                cancelled.setText("No file Selected");
                cancelled.exec();
                }
                else

                1 Reply Last reply
                0
                • M mjgfm

                  It happens while running the code in Qt Creator. I have not tried creating an executable program so I can't say if it will happen outside Qt Creator.. but isn't that how it goes, if it happens in debug mode it will happen during exe run as well? OS is Windows 7. Qt Creator Version is 5.7.0. This is the error message
                  0_1482398217006_upload-918dd5b9-ee7e-40e9-9bf9-1aa4caba4c5c

                  m.sueM Offline
                  m.sueM Offline
                  m.sue
                  wrote on last edited by
                  #8

                  @mjgfm said in Runtime error when cancelling QFileDialog:

                  I have not tried creating an executable program

                  I do not understand how QtCreator can execute this code without you having an executable program.
                  -Michael.

                  1 Reply Last reply
                  0
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Hi
                    You should try with a clean default project.
                    And only call QFileDialog::getOpenFileNames(xxx)

                    If it can crash on that line alone then your windows is not in fully working condition :)

                    1 Reply Last reply
                    1

                    • Login

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