In QT Creator I decided to create autotest project where my tests will sit. My first step was to make my main project subdirs,but when I added the subdirs template , project won't build. It seems all classes which inherit from QObject are now "unknown type".
Here is my main project .pro file:
QT += quick
QT += core gui
QT += network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = subdirs
# the line above breaks project. Whithout it project compiles...
CONFIG += c++11 qml_debug declarative_debug console
win32 {
LIBS += -lws2_32
}
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
applicationservice.cpp \
blinkingtimer.cpp \
shapes/genericshape.cpp \
shapes/circle.cpp \
shapes/textprint.cpp \
shapes/tracksection.cpp \
shapes/triangle.cpp \
main.cpp \
shapes/square.cpp \
shapes/trainsignal.cpp \
cliarguments.cpp \
guimanager.cpp \
desktopgeometry.cpp \
tinyxml2/tinyxml2.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES +=
HEADERS += \
applicationservice.h \
blinkingtimer.h \
customtypes.h \
shapes/genericshape.h \
shapes/circle.h \
shapes/textprint.h \
shapes/tracksection.h \
shapes/triangle.h \
shapes/square.h \
shapes/trainsignal.h \
cliarguments.h \
guimanager.h \
desktopgeometry.h \
tinyxml2/tinyxml2.h
A project cannot be both subdirs and app at the same time, which is what you're trying here.
The best way would be to move your main project into a subfolder (I've called it "App" here), same as your tests project ("Tests"). You then add an overarching subdirs project in the root folder:
Folder structure:
Rootdir/
|-- RootProject.pro
|-- App/
|-- App.pro
|-- <source files etc>
|-- Tests/
|-- Tests.pro
|-- <source files etc>
RootProject.pro
TEMPLATE = subdirs
SUBDIRS += \
App \
Tests \
Related
My Qt version is 5.12.2. I have added DEFINES += QCUSTOMPLOT_USE_OPENGL in my .pro file. My .pro file is shown below:
#-------------------------------------------------
#
# Project created by QtCreator 2019-04-05T21:23:52
#
#-------------------------------------------------
QT += core gui
QT += charts
QT += network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
TARGET = oscilloscope_msvc2015
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += QCUSTOMPLOT_USE_OPENGL
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
mainwindow.cpp \
fourier.cpp \
plotdata.cpp \
datathread.cpp \
axisthread.cpp \
qcustomplot.cpp
HEADERS += \
mainwindow.h \
fourier.h \
plotdata.h \
datathread.h \
axisthread.h \
qcustomplot.h
FORMS += \
mainwindow.ui \
fourier.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
res.qrc
but when I use setOpenGl(true) to turn on OpenGL, it keeps reporting error:
void QCustomPlot::setOpenGl(bool, int) QCustomPlot can't use OpenGL because QCUSTOMPLOT_USE_OPENGL was not defined during compilation (add 'DEFINES += QCUSTOMPLOT_USE_OPENGL' to your qmake .pro file)
So how to turn on OpenGL acceleration in QCustomPlot?
Try to run qmake and then rebuild.
I had this problem and after doing these, it was ok.
I found a few other hits when searching for this particular problem, but i cant get my setup to work with my unit test project(s).
project info: ( optional reading)
I am in the beginning of my final undergraduate project, where I am to
create an IDE for the language Promula and the the
verification tool Spin. The professor I am doing this with expects to
use it in his classes and for future undergraduates to keep improving. It is also meant to be a open source project everyone can contribute to.
Spin tool
my folder struture:
QSpin
-QSpin.pro
-QSpinApplication
--QSpinapplication.pro
--QSpinApplication.pri
--include
---Workspace
----*.h
--src
---Workspace
----*.cpp
-QSpinApplicationTests
--QSpinApplicationTests.pro
--WorkspaceGroupTests
---WorkspaceGroupTests.pro
----some cpp testfile
My QSpinApplication compiles and runs without any problems. The import of what i have so can be imported.
#include <Workspace/(file_name).h>
However in my test project WorkspaceGroupTests i want to include headers in the same way, but i cant get it to work. Beside that i assume the test project need to know where the cpp files are. If i dont use any of the application headers the test project compiles and runs with the default test case.
at the moment i am using a default shadow build with its root folder in the QSpin folder.
Any idea of how i get my test project working correctly, to actual be able to test my application classes?
QSpin.pro:
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
QSpinApplication\QSpinApplication.pro \
QSpinApplicationTests
QSpinApplication.pro:
QT += quick qml gui
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES +=src/main.cpp
include(QSpinApplication.pri)
RESOURCES += qml.qrc
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
QSpinApplication.pri:
#//DEPENDPATH += $$PWD
INCLUDEPATH += ./include
SOURCES +=src/workspace/workspaceview.cpp \
src/workspace/groupitem.cpp \
src/workspace/groupitemsplitter.cpp \
src/workspace/workspacegroup.cpp \
src/workspace/workspaceviewattached.cpp \
src/workspace/workspaceviewiteminfo.cpp \
src/workspace/workspacegrouplinknode.cpp
HEADERS += \
include/workspace/workspaceview.h \
include/workspace/groupitem.h \
include/workspace/groupitemsplitter.h \
include/workspace/workspacegroup.h \
include/workspace/workspaceviewattached.h \
include/workspace/workspace.h \
include/workspace/workspaceviewiteminfo.h \
include/workspace/workspacegrouplinknode.h
QSpinApplicationTests.pro:
TEMPLATE = subdirs
SUBDIRS += \
WorkspaceGroupTests
WorkspaceGroupTests.pro:
QT += testlib
QT -= gui
DEPENDPATH+=./../../QSpinApplication
include(./../../QSpinApplication/QSpinApplication.pri)
CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += tst_workspacegrouptests.cpp
Not sure if I understood well but in general, what I would advise is to create a separate structure for "lib" where you put logic code that can be tested, so default structure would look like that:
Structure:
├───app.pro
├───lib.pro
└───tests.pro
Then you put in your lib.pro:
TARGET = NameOfTarget
TEMPLATE = lib
CONFIG += staticlib
and add in your tests.pro, and in app.pro:
LIBS += -L../lib -lNameOfTarget
At end it should be possible without problems to include in app directory and in test:
#include "anyHeaderFromLib.h" .
As an extra addition for Michal Kalinowski answer:
Looks like this will work only for Linux/Mac, in case of Windows you should handle it on that way:
win32:CONFIG(release, debug|release): LIBS += -L../lib/debug -lNameOfTarget
else:win32:CONFIG(debug, debug|release): LIBS += --L../lib/release -lNameOfTarget
else:unix: LIBS += -L../lib -lNameOfTarget
Some more context can be get here: https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
I downloaded a project named MVCClone from github. It's a QT project that needs CGAL to run. I installed boost and CGAL on my Windows 10. QT 5.5.1 mingw is installed.
When I build the project I get the error:
boost/config.hpp: No such file or directory
in one of CGAL header files.
Here is the .pro file for QT project:
QT += core gui opengl
TARGET = MVCDemo
TEMPLATE = app
SRC_DIR = $${PWD}/src
SOURCES += $${SRC_DIR}/glwidget.cpp \
$${SRC_DIR}/main.cpp \
$${SRC_DIR}/mainwindow.cpp \
$${SRC_DIR}/MVCCloner.cpp \
$${SRC_DIR}/sourcewidget.cpp \
$${SRC_DIR}/utils.cpp
HEADERS += $${SRC_DIR}/CloningParameters.h \
$${SRC_DIR}/CoordinatesMesh.h \
$${SRC_DIR}/glwidget.h \
$${SRC_DIR}/mainwindow.h \
$${SRC_DIR}/mvcshaders.h \
$${SRC_DIR}/MVCCloner.h \
$${SRC_DIR}/sourcewidget.h \
$${SRC_DIR}/utils.h
## using pkg-config
#linux {
# CONFIG += link_pkgconfig
# PKGCONFIG += glu
#}
# CGAL
*-g++* {
QMAKE_CXXFLAGS += -frounding-math
}
LIBS += -lCGAL -lgmp
RESOURCES += images/images.qrc \
src/shaders.qrc
LIBS += "C:/dev/CGAL-4.8.1/lib/release/CGAL_Core-vc140-mt-4.8.1.lib"
INCLUDEPATH += "C:/dev/CGAL-4.8.1/include"
LIBS+="C:\local\boost_1_61_0\lib64-msvc-14.0"
INCLUDEPATH +="C:/local/boost_1_61_0/lib64-msvc-14.0"
Also I can't #include any boost headers in the project.
INCLUDEPATH +="C:/local/boost_1_61_0/lib64-msvc-14.0"
should be:
INCLUDEPATH +="C:/local/boost_1_61_0/"
there you will find a folder named boost containing all headers.
I have been tasked with converting a project that was built in QtCreator to .NET
The first thing I am trying to do is build the project in QtCreator so that I can step thru its execution to follow the flow and see some of the variables at play (real values).
When I build, I get a lot of errors like this:
error: C1083: Cannot open include file: 'QFrame': No such file or directory
error: C1083: Cannot open include file: 'QMainWindow': No such file or directory
error: C1083: Cannot open include file: 'QSpinBox': No such file or directory
When I search my drive, I do find 'QFrame', but in paths that have things like this in them:
android_armv7
msvc2013_64
winphone_x86
winrt_x64
Here is my .pro file
TEMPLATE = app
CONFIG *= warn_on
CONFIG(debug, debug|release): CONFIG *= console
QT += widgets
#------------------------------------------------------------
# Source Files
#------------------------------------------------------------
FORMS += \
GUIDemo.ui \
Registration.ui \
HEADERS += \
CustomFrames.h \
GUIDemo.h \
MultiRadar.h \
QControlUtils.h \
ScannerInfo.h \
TabAdvanced.h \
TabBScan.h \
TabGuardZone.h \
TabImage.h \
TabInstallation.h \
TabPPI.h \
TabTargets.h \
SOURCES += \
CustomFrames.cpp \
GUIDemo.cpp \
MultiRadar.cpp \
QControlUtils.cpp \
ScannerInfo.cpp \
TabAdvanced.cpp \
TabBScan.cpp \
TabGuardZone.cpp \
TabImage.cpp \
TabInstallation.cpp \
TabPPI.cpp \
TabTargets.cpp \
main.cpp \
#------------------------------------------------------------
# Include directories
#------------------------------------------------------------
INCLUDES = \
../../include \
#------------------------------------------------------------
# UI Generation
#------------------------------------------------------------
CONFIG(debug, debug|release): TARGET_DIR = debug
CONFIG(release, debug|release): TARGET_DIR = release
UI_DIR = GeneratedFiles
MOC_DIR = $${UI_DIR}/$${TARGET_DIR}
INCLUDEPATH += $${UI_DIR}
#------------------------------------------------------------
# Libraries
#------------------------------------------------------------
LIBS += \
-L../../lib/$${TARGET_DIR} \
-lNRPClient \
-lNRPPPI \
#------------------------------------------------------------
# Final config
#------------------------------------------------------------
#set the qmake variables
DEPENDPATH += $$INCLUDES
INCLUDEPATH += $$INCLUDES
The folder indicated by INCLUDES is there and contains a bunch of project-specific header files.
I have a feeling that I am missing some part of QtCreator that would allow me to build for Win7.
Qt Creator is just the IDE. You need to have installed the Qt libraries as well, so make sure you have them.
These errors suggest that the project's .pro file should add the widgets module:
QT += widgets
This makes sure the project includes the right include directories (the ones that have QFrame and such) and library directories on Qt 5.x.
EDIT:
After a little bit of chat, we discovered that Qt SDK for MS2010 was installed, but since the OP had MS2013 on his box, what solved the problem was downloading and installing Qt SDK for MS2013.
I want to develop a Qt GUI application with MongoDB serving as the back-end database. So I need to use MongoDB C driver or C++ driver.
Truth be told, it's kind of difficult to build a C++ driver under Windows. When I do "scons", it can't find boost and I have installed boost. I don't know why.
So I choose MongoDB C driver. When I did "scons", it went all well and generated four files (bson.lib, bson.dll, mongoc.lib, mongoc.dll). But I don't know exactly how to use these libs and DLL's to make it work in Qt Creator.
I haven't done the C driver, but I'm in the process of doing the C++ one with Qt Creator. You need to include the boost libraries in your project, and--for the version of MongoDB client C++ that I downloaded anyway--they need to be the Boost 1.49 libraries, no more and no less. Download it and just have it build all the libraries, even though you only need about four of them for this. The following is the relevant code from my Qt Creator .pro file, and note that everything in my C:/MongoDB folder is downloaded from the MongoDB source, or at least built by scons from that direct download.
INCLUDEPATH += C:/MongoDB/src \
C:/MongoDB/src/mongo/client \
C:/MongoDB/src/third_party/boost \
C:/MongoDB/src/third_party/boost/boost \
C:/MongoDB/src/mongo \
C:/MongoDB/src/third_party/boost/boost/algorithm \
C:/MongoDB/src/third_party/boost/boost/asio \
C:/MongoDB/src/third_party/boost/boost/bind \
C:/MongoDB/src/third_party/boost/boost/concept \
C:/MongoDB/src/third_party/boost/boost/config \
C:/MongoDB/src/third_party/boost/boost/container \
C:/MongoDB/src/third_party/boost/boost/date_time \
C:/MongoDB/src/third_party/boost/boost/detail \
C:/MongoDB/src/third_party/boost/boost/exception \
C:/MongoDB/src/third_party/boost/boost/filesystem \
C:/MongoDB/src/third_party/boost/boost/function \
C:/MongoDB/src/third_party/boost/boost/functional \
C:/MongoDB/src/third_party/boost/boost/integer \
C:/MongoDB/src/third_party/boost/boost/io \
C:/MongoDB/src/third_party/boost/boost/iterator \
C:/MongoDB/src/third_party/boost/boost/math \
C:/MongoDB/src/third_party/boost/boost/move \
C:/MongoDB/src/third_party/boost/boost/mpl \
C:/MongoDB/src/third_party/boost/boost/numeric \
C:/MongoDB/src/third_party/boost/boost/optional \
C:/MongoDB/src/third_party/boost/boost/pending \
C:/MongoDB/src/third_party/boost/boost/preprocessor \
C:/MongoDB/src/third_party/boost/boost/program_options\
C:/MongoDB/src/third_party/boost/boost/random \
C:/MongoDB/src/third_party/boost/boost/range \
C:/MongoDB/src/third_party/boost/boost/regex \
C:/MongoDB/src/third_party/boost/boost/smart_ptr \
C:/MongoDB/src/third_party/boost/boost/spirit \
C:/MongoDB/src/third_party/boost/boost/system \
C:/MongoDB/src/third_party/boost/boost/test \
C:/MongoDB/src/third_party/boost/boost/thread \
C:/MongoDB/src/third_party/boost/boost/tuple \
C:/MongoDB/src/third_party/boost/boost/type_traits \
C:/MongoDB/src/third_party/boost/boost/typeof \
C:/MongoDB/src/third_party/boost/boost/units \
C:/MongoDB/src/third_party/boost/boost/unordered \
C:/MongoDB/src/third_party/boost/boost/utility \
DEFINES += _UNICODE \
SYM_STATICLIB
QMAKE_CFLAGS_RELEASE += /MT
QMAKE_CXXFLAGS_RELEASE += /MT
QMAKE_CFLAGS_DEBUG += /MTd
QMAKE_CXXFLAGS_DEBUG += /MTd
LIBS += -L$$PWD/../../../../../../MongoDB/src/third_party -lWS2_32
LIBS += -L$$PWD/../../../../../../MongoDB/src/third_party -lDbgHelp
CONFIG(debug, debug|release) {
LIBS += -LC:\MongoDB\build\win32\debug\client_build -lmongoclient
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/thread/build/msvc-10.0/debug/link-static/runtime-link-static/threading-multi/ -llibboost_thread-vc100-mt-sgd-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/date_time/build/msvc-10.0/debug/link-static/runtime-link-static/threading-multi/ -llibboost_date_time-vc100-mt-sgd-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/system/build/msvc-10.0/debug/link-static/runtime-link-static/ -llibboost_system-vc100-sgd-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/filesystem/build/msvc-10.0/debug/link-static/runtime-link-static/ -llibboost_filesystem-vc100-sgd-1_49
}
CONFIG(release, debug|release) {
LIBS += -LC:\MongoDB\build\win32\release\client_build -lmongoclient
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/thread/build/msvc-10.0/release/link-static/runtime-link-static/threading-multi/ -llibboost_thread-vc100-mt-s-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/date_time/build/msvc-10.0/release/link-static/runtime-link-static/threading-multi/ -llibboost_date_time-vc100-mt-s-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/system/build/msvc-10.0/release/link-static/runtime-link-static/ -llibboost_system-vc100-s-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/filesystem/build/msvc-10.0/release/link-static/runtime-link-static/ -llibboost_filesystem-vc100-s-1_49
}
Note that Qt is known to misbehave when built against static C++ runtimes, so it's probably best to follow the advice I was given here and wrap the driver in a non-Qt C++ dll which is built against static runtimes, and then use that dll inside the main Qt app which would be built against the dynamic runtimes.
Also note that I had to manually copy the winsock and help libs into a root folder and include them manually because Qt Creator wouldn't accept the "Program Files (x86)" path since it had spaces in it.
I realize this isn't a "Mongo C" answer, but you did mention that you're only using the C driver out of frustration getting the C++ one to work, so I thought I'd share what I know.