when I compile the codes which has database connection, there's an error like,
QtSql: No such file or directory
I suppose that the sql library must be in Qt, but I dont have any idea why an error occured ?
what to do for enable the database's libraries?
Can you help me please, thanks
From QtSql documentation,
In your .pro file you have to add,
QT += sql
AFAIK there is no separate library to be included for SQL module. It's enough if you add the above line to your .pro file.
Since you are not aware of adding libraries,
From qmake documentation, libraries can be added by using LIBS keyword.
An example from the same documentation itself..
unix:LIBS += -lmath -L/usr/local/lib
win32:LIBS += c:\mylibs\math.lib
Related
Qt seems to load openssl dynamically at runtime, as seen in this question.
And apparently, it gets the system openssl. For instance, on macOS, I would rather use the homebrew-installed openssl, and package it into my dmg, so that the users don't need to install it themselves.
How can I tell Qt where to look for the libraries it links? Is there something to do with the qt.conf file?
you can do something like that in your .pro file:
win32-msvc* {
LIBS += -LC:/openssl/lib/ -llibeay32
LIBS += -LC:/openssl/lib/ -lssleay32
INCLUDEPATH += C:/openssl/include
}
left click on your project -> add library -> external library -> choose the .lib file and the include folder for the library. check for which platform it is.
It will put the specific platform dependend commands to your project .pro filefile.
I am new to Qt. Downloaded source code for a Qt application of SourceForge, and tried to build and run it. After working through a few similar problems by adding QT += statements to .pro files, I am stuck on this one:
On attempting to build in Qt Creator, I get errors saying
error: C1083: Cannot open include file: 'QPrinter': No such file or directory
I tried adding QT += printsupport to the .pro file, cleaning, and rebuilding, but that gives this error
Error: dependent '..\..\..\..\..\..\..\..\..\..\..\Qt\Qt5.1.1\5.1.1\msvc2012_64\include\QtPrintSupport\qtprintsupportglobal.h' does not exist."
When I go to C:\Qt\Qt5.1.1\5.1.1\msvc2012_64\include\QtPrintSupport, qtprintsupportglobal.h IS THERE!
You have to add QPrinter Support to your project's .pro file:
QT += printsupport
In my case the solution was to
Delete the shadow build directory and build again
after adding printsupport, as #KubaOber suggests in the comments.
Easy mistake to make: After you edit your .pro
QT += printsupport
You have to SAVE the file before your .h will be aware of it.
Because QMake will eventually be dropped in favor of CMake, here's the solution for CMake users:
Pass PrintSupport to the find_package call, to the right side of COMPONENTS, like in this example:
find_package(Qt5 ${QT5_MIN_VERSION} REQUIRED COMPONENTS Core Gui Qml QuickControls2 PrintSupport)
I wrote a small app with qt and opengl (code) and I want to compile it static now.
So i downloaded Qt library and compile it static using this guide.
I added a line CONFIG += static to the pro file cd to the project location and hit:
make clean
qmake -config release
make
but I am getting several undefined references like:
qpixmapdata_gl.cpp:-1: error: undefined reference to `_imp___Z14qt_defaultDpiYv'
What I am doing wrong? Do I need to add the libs to the pro file? How do I do this and more important what libs should I use?
I tried something like this with no result:
LIBS += C:\Qt\4.7.3\bin\QtOpenGL4.dll
I see that symbol is defined in qfont.cpp, so it should be there. I would try to add:
QT += gui
in your .pro file. And I suppose you need:
QT += core
also.
EDIT: Try also to check that the symbol is included in the libQtGui.lib and the line used to compile.
Are you using the same compiler also? The mangling reported seems that of gcc. Did you compile Qt libraries with mingw or nmake?
I made a custom library and i compiled it into a dll (qustom.dll).
Now i want to compile another project using this dll.
What i did is to import the header files in the project and add this line in my .pro file
LIBS += -lqustom
but i get "error: cannot find -lqustom"
also i tried
LIBS += qustom.dll
and
LIBS += -libqustom.a
qustom.dll is in the project directory
Also i tried
OTHER_FILES += \
qextserialport1.dll
but didn't work either
Am i missing something here?
Missing a path perhaps? -L/path/to/dlls -ldllname
Qt plays nicely with CMake. I use that and I never get dependency/path headaches like this any more.
I want to use CTelephony API in Qt Symbian project but after including etel3rdparty.h and etel3rdparty.lib as library and header in .pro file like this:
LIBS += C:/NokiaQtSDK/Symbian/SDK/epoc32/release/armv5/lib/etel3rdparty.lib
INCLUDEPATH += C:/NokiaQtSDK/Symbian/SDK/epoc32/include
I am getting a lot of compilation errors.
Please share if someone faced and find the solution of this problem.
You are not supposed to include each library with the complete path in the .pro file. You need only the name of the lib, without the extension, prefixed with -l, i.e. in your case
LIBS += -letel3rdparty
Also, you would normally not need to add epoc32\include to the include path, as it's added by default.