Cannot #include <QtSvg> - c++

I am trying to include QtSvg in mainwindow.cpp but when I compile it says cannot open include files: QtSvg. I have already added this(QT += svg) in my *.pro file. May I know what could be the problem?

After "pro" file change, it is necessary to launch qmake. After that it is possible to compile application.

Related

Qt Cannot open include file: 'QNetworkAccessManager': No such file or directory

I'm new to Qt, and I keep running into weird errors. Here is one of them: I have a class named NetworkHandner that includes QNetworkAccessManager (#include <QNetworkAccessManager>). I added QT += network in my .pro file. Everything works great. However, when I try to include my NetworkHandler class in mainwindow.h (#include "networkhandler.h"), I get the error in the title. I am really confused, as everything compiles and works great until I include the networkhandler header inside another header. Can anyone point me in the right direction? How can I fix this problem? Thank you in advance for any help!
QNetworkAccessManager comes with the QtNetwork module. You could do this: #include <QtNetwork/QNetworkAccessManager>, which should compile. However, it will not link, you need to link to QtNetwork. To achieve this, you should tell QMake that you're using QtNetwork. Add this to your .pro project file: QT += network.
This has two effects: first, the compiler will look for include files in the QtNetwork subdirectory too (so you don't need to include <QtNetwork/QNetworkAccessManager>, <QNetworkAccessManager> will work just fine). Secondly, the linker will link to QtNetwork too. So everything will work just fine.

Qt5 migration: Cannot open include file: 'qtconcurrentexception.h': No such file or directory

I'm migrating a project to Qt5, and I'm getting this error (it compiles fine for Qt4):
fatal error C1083: Cannot open include file: 'qtconcurrentexception.h': No such file or directory
for this line:
#include <qtconcurrentexception.h>
I include this file in order to use QtConcurrent::Exception. Has the header file for QtConcurrent::Exception changed?
All of the below applies to Qt 5 only.
If you ever need an include of the form <QtModule/QHeader>, it means that you did not add the relevant Qt module to your project file. You will get linking errors later, even though such hacked include seems to work during compilation.
QtConcurrent::Exception is deprecated and simply forwards to QException from the core module. So:
#include <QException>
If you wish to use the concurrent module for something else in Qt 5, you should #include <QtConcurrent>. You should also add Qt += concurrent to your project file, and re-run qmake.

qt windows include boost thread header failed

I want to include boost in my qt application in windows, So:
In my .pro file, I add:
INCLUDEPATH += D:/library/boost_1_55_0
In main.cpp
#include <boost/thread/mutex.hpp>
When build, cause this error:
Cannot open include file: 'boost/thread/mutex.hpp'
I am sure the path is correct. And it is very strange.
The issue is that you have to re-run qmake explicitly. Here you can find the corresponding long-standing issue:
Creator should know when to rerun qmake

QtCreator: How to compile external source files

I have my C++ project files and want to create an additional graphical user interface for these sourcefiles. I am using windows, MVSC2012 and Qt 5.1.1 with Qt Creator 2.8.1.
So here is what i have:
My QtCreator project folder, including the following auto-generated files
c:/creatorProject/creatorProject/main.cpp
c:/creatorProject/creatorProject/mainwindow.cpp
c:/creatorProject/creatorProject/mainwindow.h
c:/creatorProject/creatorProject/mainwindow.ui
c:/creatorProject/creatorProject/creatorProject.pro
c:/creatorProject/creatorProject/creatorProject.pro.user
Furthermore I the source files with the "logic" in a separated folder, e.g.
c:/programLogic/myFunctions.h
c:/programLogic/myFunctions.cpp
So I simply want to add these files to my QtCreator project so that I can e.g. include "myFunctions.h" and work with it.
My attempt: I used Qt Creator and added myFunctions.h respectively myFunctions.cpp by using "creatorProject >> right click >> add existing file..". After doing that my creatorProject.pro looks like this:
[...]
SOURCES += main.cpp\
mainwindow.cpp \
../../programLogic/myFunctions.cpp
HEADERS += mainwindow.h \
../../programLogic/myFunctions.h
Looks totally fine for me. Qt Creator even shows these files within the project explorer! However I have trouble using myFunctions.h within mainwindow.cpp.
#include "myFunctions.h" // Include can not be found
#include "../../programLogic/myFunctions.h" // Include is found but I get linker errors since myFunctions.cpp is not compiled?!
What is wrong within my setup?
You need to add the INCLUDEPATH also in your .pro file.
Something like:
INCLUDEPATH += "C:/programLogic"

Error in inclusion of <QNetworkAccessManager>,<QNetworkReply> in cpp file of a BB10 app development

I am currently working on BB10 app development and trying for some HTTP connection demo app.
But in the cpp file is giving a ? in front of inclusion statement #include <QNetworkAccessManager> saying Unresolved Inclusion : <QNetworkAccessManager>.
Anyone please help me.
Thanks in advance.
QNetworkAccessManager comes with the QtNetwork module. You could do this: #include <QtNetwork/QNetworkAccessManager>, which should compile. However, it will not link, you need to link to QtNetwork. To achieve this, you should tell QMake that you're using QtNetwork. Add this to your .pro project file: QT += network.
This has two effects: first, the compiler will look for include files in the QtNetwork subdirectory too (so you don't need to include <QtNetwork/QNetworkAccessManager>, <QNetworkAccessManager> will work just fine). Secondly, the linker will link to QtNetwork too. So everything will work just fine.
You can read more about using Qt modules here.