How to create a Qt application using MSVC14?

258 views Asked by At

Hello I have download qt-opensource-windows-x86-winrt-5.5.1.exe from the QT website. I've launched the installer, It finishes successfully.

But I can create a QT application using MSVC 2015. So if I create new Project->Templates->Visual C++->QT->QT GUI Application

I get the error:

The following error occurred: 
Unable to find QT build!
To solve this problem specify a Qt build.
  • How could integrate QT 5.5 with MSVC14?
2

There are 2 answers

0
Tim Jenßen On

why do you want to use that old Qt version and keep in mind that the year number in the product name has nothing to do with the real version. https://omwtm.blog/2014/12/03/visual-studio-2013-version-numbers-and-updates/

0
Raindrop7 On

The easiest way I guess is to Download "qt-opensource-windows-x86-msvc2015-5.6.3.exe" from the Qt official website and install it.

https://download.qt.io/archive/qt/5.6/5.6.3/qt-opensource-windows-x86-winrt-msvc2015-5.6.3.exe.mirrorlist

1- Launch the installer until it is done.

2- Open MSVS 2015.

3- Tools->Extensions and Updates...

4- Click Online. (From the left pane).

5- No in the right pane in the search box enter: Qt.

6- The wizard should find "Qt Visual Studio Tools", "Qt Test Adapter", "Qt Package"...

7- Select QtPackage and click downlaod.

8- After download is done, click install.

9- After install is done close and reopen MSVS 2015. (so that new packages to be added and loaded). Or Click restart Visual Studio.

10- After restart of MSVS you see in the menu "QT5".

11- In the menu Click QT5->QT Options.

12- Click Add.

13- Browse to the folder: C:\Qt\Qt5.6.3\5.6.3\msvc2015

14- Click OK.

15- You don't get an error red message; Which means QT has been successfully detected.

16- You Can add "Qt Visual Studio Tools" the same way as the steps above.

17- Let's create a minimal GUI Application with MSVC2015 using QT5:

1- Open MSVC2015.

2- File->New->Project->Visual C++->Qt->Qt Gui Application.

3- click next. Leave everything as is.

4- click finish.

5- The wizard creates the project.

6- Build and Run. It should work correctly; you get a dialog.

  • The minimal program generates by the wizard:

    #include "QtGuiApplication1.h"
    
    QtGuiApplication1::QtGuiApplication1(QWidget *parent)
    : QMainWindow(parent)
    {
        ui.setupUi(this);
    }
    
  • Now if you try to run the application you've just built with MSVC from outside MSVC2015:

1- Open C:\Users(Your User name)\Desktop\QtGuiApplication1\Win32\Debug

2- You'll find the executable there: QtGuiApplication1.exe

3- Double click it.

4- It doesn't work?! Why?

5- Becuase simply you've linked Dynamically to Qt5.

6- So Copy the needed DLLs from Qt installation folder ("C:\Qt\Qt5.6.3\5.6.3\msvc2015\bin") to the same folder as you application.exe (in this case to Debug folder of your application).

7- Double click it now. It should work fine.