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. Use a QDialog box in Win32 Application

Use a QDialog box in Win32 Application

Scheduled Pinned Locked Moved Unsolved General and Desktop
qinputdialogwin32console app
4 Posts 3 Posters 1.4k 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.
  • F Offline
    F Offline
    falcon010216
    wrote on last edited by
    #1

    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.

    jsulmJ 1 Reply Last reply
    0
    • F falcon010216

      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.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • newbieQTDevN Offline
        newbieQTDevN Offline
        newbieQTDev
        wrote on last edited by newbieQTDev
        #3

        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

        jsulmJ 1 Reply Last reply
        0
        • newbieQTDevN newbieQTDev

          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

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          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