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
QtWS25 Last Chance

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 5 Apr 2018, 09:29 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.

    J 1 Reply Last reply 5 Apr 2018, 10:38
    0
    • F falcon010216
      5 Apr 2018, 09:29

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 5 Apr 2018, 10:38 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
      • N Offline
        N Offline
        newbieQTDev
        wrote on 5 Apr 2018, 13:35 last edited by newbieQTDev 4 May 2018, 13:39
        #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

        J 1 Reply Last reply 5 Apr 2018, 14:54
        0
        • N newbieQTDev
          5 Apr 2018, 13:35

          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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 5 Apr 2018, 14:54 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

          1/4

          5 Apr 2018, 09:29

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved