Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Embed QT code into Visual Studio Project

    Installation and Deployment
    3
    4
    3067
    Loading More Posts
    • 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.
    • R
      rmhughes last edited by

      Information: I have the QT SDK installed, as well as the Visual Studio 2010 add-on.

      I have a project done in C++ using Visual Studio and I would like to add just a little QT code to it. Namely:

      @bool ok;
      QString text = QInputDialog::getText(
      "Prompt", "Enter something:", QLineEdit::Normal,
      QString::null, &ok, this );
      if ( ok && !text.isEmpty() ) {
      // user entered something and pressed OK
      } else {
      // user entered nothing or pressed Cancel
      }@

      which would simply prompt the user for something.

      What would be the simplest way (if there is one) to be able to include this code in my project? Library paths, copy over some files from the QT SDK, etc.?

      1 Reply Last reply Reply Quote 0
      • B
        blex last edited by

        Please note that for QInputDialog the QApplication object is required.

        For me the simplest approach is to create *.pro file (probably using qmake -project mode) and after that generate vcproj file (qmake -t vcapp). But for the existing large MSVC-based project it may be a complex task.

        Recommendation: create the test Qt project that calls QInputDialog. Open the generated with qmake test.vcproj and add to your project the following settings:

        Compiler DEFINES

        Compiler INCLUDE paths

        Linker input libraries


        Oleksiy Balabay

        1 Reply Last reply Reply Quote 0
        • G
          giesbert last edited by

          The defines are normally: QT_LARGEFILE_SUPPORT, QT_THREAD_SUPPORT, QT_CORE_LIB, QT_GUI_LIB
          for release additionally: QT_NO_DEBUG

          Include paths are: $(QTDIR)\include
          Libraries to use are normally: qtmain.lib, QtCore4.lib,m QtGui4.lib
          additional libary paths are: $(QTDIR)\lib

          But you will have another problem:

          Did you install Qt SDK for MSVS or with QtCreator for gcc?

          If you used the one for gcc the library iunterfaces will not fit. C++ exports do not work cross compüiler from gcc to MSVC :-(

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply Reply Quote 0
          • B
            blex last edited by

            [quote author="giesbert" date="1290499607"]Did you install Qt SDK for MSVS or with QtCreator for gcc?[/quote]

            Sure, Qt should be compiled with MSCV compiler. Even better, compile it from sources to use exactly the same MSVC runtime libraries.


            Oleksiy Balabay

            1 Reply Last reply Reply Quote 0
            • First post
              Last post