Important: Please read the Qt Code of Conduct -

Use a QDialog box in Win32 Application

  • I have a win32 application using Visual Studio 2010 and QT4. The program compiles and run. In the program I try to create a QDialog box to enter a number.
    Here is the code

    #include "stdafx.h"
    #include "QtGui\qinputdialog.h"
    #include "QtGui\qmessagebox.h"
    #include "QtGui\qapplication.h"
    #include "QtCore/QDebug"

    int _tmain(int argc, char* argv[])

    QApplication app(argc, argv);
    	QTextStream cout(stdout);                      
    	// Declarations of variables
    	int answer = 0;                                 
    	do {
    		// local variables to the loop:
    		int factArg = 0;
    		int fact(1);
    		factArg = QInputDialog::getInt(0, "Factorial Calculator",
    			"Factorial of:", 1);                    
    			cout << "User entered: " << factArg << endl;
    		int i = 2;
    		while (i <= factArg) {
    			fact = fact * i;
    		QString response = QString("The factorial of %1 is %2.\n%3")
    			.arg("Compute another factorial?");     
    			answer = QMessageBox::question(0, "Play again?", response,
    			QMessageBox::Yes | QMessageBox::No);    
    	} while (answer == QMessageBox::Yes);
    		return EXIT_SUCCESS;
    return 0;


    In this application If I run I get the following output in the console
    0_1522919990572_Untitled (2).png

    This code is run in debug mode. I have the QT4 at .lib. As shows QtGuid4.dll not found but the .dll file is already there in the location. Thanks.

  • Qt Champions 2019

    @falcon010216 The library is found but not a method inside this library. Is it possible that your app is using a different Qt version at runtime than at build time? Do you have any directories containing Qt libraries in your PATH?

  • Hi jsulm.
    Thank for your replay
    This is the version of my QT.
    This is my file .pro

    QT += core
    QT += axcontainer
    QT -= gui
    CONFIG += c++11
    TARGET = myTestCOM
    CONFIG += console
    CONFIG -= app_bundle
    TEMPLATE = app
    SOURCES += main.cpp

    this is my setting's project

  • Qt Champions 2019

    @newbieQTDev said in Use a QDialog box in Win32 Application:

    This is the version of my QT.

    No this is the Qt version which was used to build QtCreator (which is a Qt app).
    You're using Qt 5.6.0