Visual Studio 2019 does not recognize Qt 6.1.2 package names - c++

I'm new to both Visual Studio and Qt, and am trying to learn how to use them together. I installed Qt 6.1.2 and VS 2019 Professional, and then installed Qt VS Tools and set them up.
To learn, I attempted to recreate the notepad getting-started excercise (https://doc-snapshots.qt.io/qt6-dev/qtwidgets-tutorials-notepad-example.html), but I am having trouble with Visual Studio not being able to identify a lot of package names (or whatever it's called, like <QApplication>). I can recreate the excercise in Qt Creator just fine. I can also see and access the *.h files of Qt in Visual Studio just fine (e.g. #include <QtWidgets/qtextedit.h>).
Examples:
#include <QApplication> //Is accepted in Qt Creator, but not in VS
#include <QtCore/QCoreApplication>// Seems to work in Visual Studio, and roughly do the same thing?
#include <QMainWindow> //Is accepted in Qt Creator, but not VS (can't find src file) and I can't find what the suitable equivalent would be
I set up the project as a Qt Widgets Application, and I think Qt VS Tools automatically added the Qt installation include path, path to the .libs files, and names of the .lib files to my project settings (I can see something like $(Qt_INCLUDEPATH_) at the appropriate spots in my project properties).
Is there anything I can change in my project properties to make VS understand the Qt package names or does Qt VS Tools use other names for the packages?

Related

Cannot open include file with Qt: "No such file or directory"

I'm new to C++ and programming, and trying to work on a little project, using Qt/Qt Creator .
I was using the MinGW compiler, but especially for this project I will need to use the MSVC compiler (since I need QtWebEngineWidgets).
I have Qt 5.8 and I'm using Qt Creator. I downloaded Microsoft Visual Studio 2015 (Community), and also installed wdk and winsdk 2015 (1703 version) from Microsft's website, and configured my kit. It took a while!
Unfortunately, i have an error when I try to run my program: looks impossible to include QtWidgets or QtWebEngineWidgets.
When I changed the kit of my project (from MinGW to MSVC 2015), I tried to run it but I had another error:
Error from the original project
I wanted to avoid it by creating a new Qt empty project, and I just copied/pasted the source code. Now it looks a bit better, but as you can see I can't include QtWebEngineWidgets and QtWidgets.
Here is the C1083 error
This is what the compiler says
Note: After I added #include <QApplication> and #include <QPushButton> in the main, and he's doing the same thing with QApplication but don't say anything about QPushButton.
Any idea about what happend?
Thank you very much
Right click on project on visual studio -> click properties (on the bottom) -> go to C/C++ -> all options -> find additional include directories and there add path to your QT include folder.

Building QT with Visual Studio

I know there have been a few questions before regarding this, but not too much up to date.
I am developing a project with Visual Studio 2015 express edition and I wish to add a GUI to my project via QT.
The latest version of QT (5.8.0) has a VS 2015 version, so I assume it is compiled using Visual Studio instead of MinGw.
Sorry if this is a very noob question. I have no experience with QT, but how do I then integrate my QT project into my VS project, do I build the GUI code first in QT?
If I will create a GUI using the .ui file in QT and then generate the source code for this, can I just copy the source code to my VS Project. I assume I have to configure the project file in VS as how will VS know where to find the dlls and header files for QT? Thanks in advance
You need the VS Tools for Qt. They work with >= Visual Studio 2013 Community Edition.
You can get them here and all information about how to use them.
Qt VS Tools integrate the Qt development tools into Microsoft Visual Studio 2013, and later. This enables developers to use the standard Windows development environment without having to worry about Qt-related build steps or tools.
The main features of Qt VS Tools are:
Wizards for creating new Qt projects and classes.
Automated build setup for the Meta-Object Compiler (moc), User Interface Compiler (uic), and Resource Compiler (rcc).
Import and export of Qt project files (.pro) and project include files (.pri).
*Automated conversion of a Qt VS Tools project to a qmake project, or the other way around.
Integrated Qt resource management.
Integrated Qt documentation.
Debugging extensions for Qt data types.

Export Visual Studio project to Qt Project

I would like to export my Visual Studio Project to a Qt project.
How to generate a .pro file from a Visual Studio Project? I installed the Qt Add-In but I don't find such option.
With Visual Studio Qt plugin installed (officially named Qt VS Tools, can be downloaded from here), just:
Open your solution.
Select any Qt-based project from your solution (or any file within that project).
Go to menu Qt VS Tools > Create basic .pro File.... If you are using an old version of the plugin, menu may be named Qt5.
Select the projects you want to export. Project tags (.pro options, only in newest plugin versions) are automatically extract from your current project, you can modify them if needed or do it later when the .pro is created.
Run qmake or open it from Qt Creator.
PS: depending on your VS and Qt versions you may need an older version of the plugin. I'm assuming Qt 5 here.
Hope it helps.

How to use Qt Creator with Visual C++ compiler on windows?

I installed Visual Studio 2008, Qt 4.8 libraries for vs2008 and Qt add in. I can build Qt projects in VS2008. But it's very inconvenient for me. When I open Qt project in Qt creator it can't compile because can't find qmake.
So, how to build projects using Qt Creator on windows.
Use CMake to build your software. With CMake you can:
-Build your project on a continuous integration server
Compile with different compilers (Microsoft, gcc, clang) to get additional static checking.
Open the top level CMakeLists.txt with creator as a project file.
Have CMake create Visual Studio project files.
If you want to fix Creator only:
Qt Creator needs to know where your Qt installation is. Choose the green Qt symbol in the settings menu, klick Qt Version and enter the path to qmake. Then Qt Creator should be ready to go.
hope this will help its having easy steps with some solution of errors that one may encounter during installation http://qtitkvtkhelp.blogspot.in/2012/11/qt-installation-prerequisite-1.html

Instruction for installing an environment with Qt and Qt integration with Visual Studio 2008

I want to use Qt lib but I don't know how to install Visual Studio 2008+Qt+Qtintegration. I have read some forums, that step by step tell what to download, where to download from, and then what to do. But that was for old versions of mentiond products.
I ask to Qt developers tell me the way to install these items on Windows. Any forum or site will be fine.
Thanks.
To get QT working with dev studio you need to install two things.
First, a copy of the QT Visual Studio Libraries.
And the QT Visual Studio Addin.
http://qt.nokia.com/downloads/windows-cpp-vs2008
http://qt.nokia.com/downloads/visual-studio-add-in
Download the QT sdk, and install it. It usually installs into a folder like
c:\qt\4.6.2
Then, install the visual studio addin. The addin should add (At least) two new things to Visual Sutdio. A new "Qt" project in the Create New Project Wizard, and a Qt menu.
Qt supports building your project against multiple builds of Qt, so the first thing you need to do is go to the Qt menu, and point it to the directory you installed the Qt SDK to. It all went well it should auto populate with c:\qt\4.6.2
Then, use the Wizard to create a new Qt project in Visual Studio.
If you are creating your first Qt project in Visual Studio this way, there is no need to fiddle with .pro files or doing any kind of "stuff" outside Visual Studio to get a project going. The Visual Studio addin sets up the workspace to do all the pre-compiles needed by the Qt build environment.
--
Note: The Qt SDK at this URL
http://qt.nokia.com/downloads/sdk-windows-cpp
comes with the MinGW runtine for GCC, and Qt Creator embedded. This is no good for Visual Studio. This build installs to a folder like
c:\Qt\2010.2