Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Embed QT code into Visual Studio Project
QtWS25 Last Chance

Embed QT code into Visual Studio Project

Scheduled Pinned Locked Moved Installation and Deployment
4 Posts 3 Posters 3.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.
  • R Offline
    R Offline
    rmhughes
    wrote on last edited by
    #1

    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
    0
    • B Offline
      B Offline
      blex
      wrote on last edited by
      #2

      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
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        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
        0
        • B Offline
          B Offline
          blex
          wrote on last edited by
          #4

          [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
          0

          • Login

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