简体   繁体   中英

how to link Qt with a visual studio c++ application project?

I have Qt 5.12.0 in a folder. I need to create a dll and/or a bin project that can connect with a QML program. My problem is that the vs project can't find the Qt files I need.

#include <QGuiApplication>

does not work.

This topic is the continuity of this one How to link libraries to a project on visual studio? where I shared my problems with linking my dll with my bin project and to link Qt.

So I use a batch file to set the environment variable before launching visual studio. I use these variables to get the path to the Qt include folder, Qt lib etc.

Here is what I tried. include the directory that contains the headers I need (I guess) : configuration properties -> C/C++ -> General -> other include directories ->$(QT_INC)/ . QT_INC is the path to the include folder. I also tried to write $(QT_INC)/* and $(QT_INC)/QtGui/. In any case,

#include <QGuiApplication>

couldn't compile.

i also added the path to the library folder : linker->General->Additional library directories->$(QT_LIB)/ and some lib files in : linker->entry->additionnal dependencies->Qt5Quick.lib;Qt5Gui;lib;Qt5Core.lib none of these steps creates any error. It just doesn't help to find QGuiApplication.h nor QObject or anything I need.

I know my paths are correct and that using the environment variable like this works as I linked my dll using this method, and because wrong paths generates errors.

How to add Qt to my solution or to a project ?

thanks in advance

It works. The path was incorrect. There were "/" instead of "\\" I think. And a synthax error in the batch file.

It's possible to add the header files of Qt by including the path in the properties. include just the directory include of the Qt folder. Then, include headers again and again until all the errors are gone. only for QGuiApplication, I need to include this

#include <QtGui/qtguiglobal.h>
#include <QtGui/qcoreapplication.h>

etc. all the includes of the beggining of QGuiApplication.h actually

here is the link to my other post I made about linking Qt to visual studio. How to link libraries to a project on visual studio? The problem was about the path to the dll.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM