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. QFileDialog :: getExistingDirectory () run with Error
Forum Updated to NodeBB v4.3 + New Features

QFileDialog :: getExistingDirectory () run with Error

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 4.5k Views 1 Watching
  • 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.
  • V Offline
    V Offline
    VladimirPivovar
    wrote on last edited by
    #1

    Hi
    I have a problem with code: "static QString dir = QFileDialog :: getExistingDirectory ();".
    When I call this code section CASE comes with an error message: "Microsoft Visual C + + Runtime Library. This application has requested the Runtime to terminate it in an unusual way". At compile time all is well. But when the - mistake. I do not know why. I tried to call in another project-the same.

    I want to get the path to the selected directory.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Leave out the static in front of the QString:

      @
      QString dir = QFileDialog::getExistingDirectory();
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dbzhang800
        wrote on last edited by
        #3

        Perhaps what he want is something like this:

        @
        static QString dir;
        if (dir.isEmpty())
        dir = QFileDialog :: getExistingDirectory ();
        @

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VladimirPivovar
          wrote on last edited by
          #4

          All the same run-time error:

          “Microsoft Visual C + + Runtime Library. This application has requested the Runtime to terminate it in an unusual way”

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lgeyer
            wrote on last edited by
            #5

            Run your application in debug mode to find out where it actually crashes.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              veeraps
              wrote on last edited by
              #6

              Would copy the binary file (created under Release folder) to Qt bin directory and try executing it from there?

              Is it crashing in debug mode as well?

              1 Reply Last reply
              0
              • V Offline
                V Offline
                VladimirPivovar
                wrote on last edited by
                #7

                in debug and in release mode:

                "QWidget: Must construct a QApplication before a QPaintDevice

                Invalid parameter passed to C runtime function.
                Invalid parameter passed to C runtime function.

                "

                I run code here:

                @

                #include <shlobj.h>
                #include <QtGui/QApplication>
                #include <QObject>
                #include <QDebug>
                #include <QFileInfo>

                int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrev,PSTR szCmdLine,int iCmdShow)
                {
                ....
                switch (uMsg)
                {
                case IDC_CHANGE_DIR:
                static QString dir;
                if (dir.isEmpty())
                dir = QFileDialog :: getExistingDirectory ();
                }
                break;
                ...
                }
                @

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  VladimirPivovar
                  wrote on last edited by
                  #8

                  A similar problem is discussed here, but I can not figure out what to do to bring up a dialog box to select the folder:

                  http://www.qtforum.org/article/24470/calling-qt-gui-dll-from-mfc-application.html

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dbzhang800
                    wrote on last edited by
                    #9

                    I couldn't figure out why you using Qt in such a way, can you give us some reasons?

                    [quote author="VladimirPivovar" date="1338551944"]in debug and in release mode:

                    "QWidget: Must construct a QApplication before a QPaintDevice

                    Invalid parameter passed to C runtime function.
                    Invalid parameter passed to C runtime function.

                    "

                    I run code here:
                    [/quote]


                    BTY, the error message is very clear, you can not construct a QWidget or it's subclass before QApplication exists.

                    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