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;
    			++i;
    		}
    		QString response = QString("The factorial of %1 is %2.\n%3")
    			.arg(factArg).arg(fact)                 
    			.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 2018

    @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.
    0_1522935084370_782e068b-c611-44e0-8fe1-c06b2fb9791d-immagine.png
    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
    0_1522935288486_fb59bc41-b7b4-4e0f-a536-e61bf3ee43ff-immagine.png
    0_1522935545658_7c99b899-7535-402d-b8e7-2fc781f0928f-immagine.png


  • Qt Champions 2018

    @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



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.