QFileDialog :: getExistingDirectory () run with Error
-
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.
-
Leave out the static in front of the QString:
@
QString dir = QFileDialog::getExistingDirectory();
@ -
Perhaps what he want is something like this:
@
static QString dir;
if (dir.isEmpty())
dir = QFileDialog :: getExistingDirectory ();
@ -
All the same run-time error:
“Microsoft Visual C + + Runtime Library. This application has requested the Runtime to terminate it in an unusual way”
-
Run your application in debug mode to find out where it actually crashes.
-
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?
-
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;
...
}
@ -
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
-
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.