How to add the librealsense2 to Qt creator? - qt

I'm pretty new with OpenCV & Intel Realsense device. I don't know how to add the librealsense2 to Qt creator. I searched many ways but they are not working for me.
I have no idea how to make it. So anybody has any hint??

First of all be sure about that you properly installed librealsense. You can check here to install.
After installation is done, you should add INCLUDEPATH and LIBS to .pro file. You didn't tell which operating system you are using. If its ubuntu, you can add simply like:
INCLUDEPATH += /usr/include/librealsense2
LIBS += -L$$DESTDIR/ -lrealsense2

Related

Qt Quick Designer Components module Static Linking not working

I'm trying to cross compile Qt Quick Designer Components to get QtQuick.Studio.Effects module on Qt 6.5 on arm64 target as I'm getting "module 'QtQuick.Studio.Effects' is not installed" when I try to to run my cross compiled qt application.
So far I have cross compiled Qt Quick Designer Components with help of this and it outputs libQuickStudioEffects.a static library. I tried to link it in .Pro file by adding the library with qt creator which generated following lines.
unix:!macx: LIBS += -L/home/user/qt/ -lQuickStudioEffects
INCLUDEPATH += /home/user/qt/
DEPENDPATH += /home/user/qt/
unix:!macx: PRE_TARGETDEPS += /home/user/qt/libQuickStudioEffects.a
lib file and executable both are in /home/user/qt/ location in target and host pc.
also I tried with following line.
LIBS += /home/user/qt/libQuickStudioEffects.a
So far executable is not detecting the lib file and giving me the above mentioned error. I can run other cross compiled qt6 programs on my target device without any issue. My host runs Ubuntu 20 and target runs on debian 11. Any help is really appreciated. Thanks.
Build the dev branch from here and it will give the dynamic QtQuick.Studio.Effects library which can be cross compiled.

Qt creator can't locate Qwt plugin

I want to use the Qwt plugin in Qt Creator, but I have troubles installing it.
I work with Debian 10, Qwt 6.1.6, Qt Creator 4.8.2 and Qt 5.11.3.
I followed these instructions:
https://qwt.sourceforge.io/qwtinstall.html#qwtinstall-unix
These are the lines that I added to .bashrc:
QT_PLUGIN_PATH="/usr/local/qwt-6.1.6/plugins:$QT_PLUGIN_PATH" export QT_PLUGIN_PATH
I added this to my .pro file (this is a new project I started):
INCLUDEPATH += /usr/local/qwt-6.1.6/include
LIBS += -L/usr/local/qwt-6.1.6/lib -lqwt
CONFIG += qwt
However, I still don't see the new widgets in the UI form designer (after restarting Qt creator). I think Qt Creator hasn't located the Qwt plugin yet (although I am not sure).
I see some explanation about QWT_INSTALL_PLUGINS in the config.pri of the downloaded Qwt from sourceforge, but I am not sure how I should edit the .bashrc file.

Qt project with Boost

I have a Qt project which requires boost. The project works fine in Linux, but compiling on windows has presented some difficulties. I have been able to make it work, but not properly, and that bothers me.
Here's the relevant part of .pro (working)
win32{
INCLUDEPATH +=C:\Boost\Boost
LIBS += "C:\Boost\Boost\stage\lib\libboost_system-mgw53-mt-1_65_1.a"
LIBS += -lws2_32
}
This does not work, but should according to the documentation I've found online.
win32{
INCLUDEPATH +=C:\Boost\Boost
LIBS += -LC:\Boost\Boost\stage\lib -lboost_system-mt
LIBS += -lws2_32
}
Note: Boost was compiled using the mingw distributed with Qt Creator.
I believe I have found the solution! I noticed that I had two copies of every boost library in \stage\lib.
libboost_system-mgw53-mt-1_65_1.a and libboost_system-mgw53-mt-d-1_65_1.a
I compiled the project using both and while the former had some warnings, the latter did not. Removing libboost_system-mgw53-mt-1_65_1.a from the folder allowed -lboost_system-mt to work just fine.
I don't know why I had both of these files, but it was undoubtedly due to me fumbling around with compiling boost.

Qt and Boost (installed through Homebrew) result in Qt compile errors

I am in the exact situation described in this question (Qt Creator on Mac and boost libraries) but the accepted answer is not working for me. I've searched around and tried all the suggestions I've found but I still end up with errors
Environment:
OSX 10.9.5
Qt 5.5.1 - Qt Creator 3.5.1 - installed using the Qt
installer
Boost 1.59.0 – installed through Homebrew
Am able to compile and run Qt apps
After creating a new Qt test application, when I add the Boost information to the .pro file (shown below) as described in the question linked above, I end up with very confusing compile errors within the Qt classes. I don't get it. Does anyone understand the conflict and know how to resolve this – I've been at it for hours now.
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = audiowaveform_test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
macx {
QMAKE_CXXFLAGS += -std=c++11
_BOOST_PATH = /usr/local/Cellar/boost/1.59.0
INCLUDEPATH += "$${_BOOST_PATH}/include/"
LIBS += -L$${_BOOST_PATH}/lib
## Use only one of these:
LIBS += -lboost_chrono-mt -lboost_system # using dynamic lib (not sure if you need that "-mt" at the end or not)
#LIBS += $${_BOOST_PATH}/lib/libboost_chrono-mt.a # using static lib
}
I finally got it working by changing this line in the .pro file:
QMAKE_CXXFLAGS += -std=c++11
to this:
CONFIG += c++11
If someone can explain what -std means in compiler speak, I would appreciate it. Does it mean that everything should be compiled as c++11?

Qt4 change linker search order

I have a Qt project which compiles library and application which links with the library.
With Qt5 everything works just fine. But with Qt4 I have one annoying problem.
On linking the application qmake for some reason brings:
-L<where_qt_libs_installed>
before
-L<build_dir/library_dir> -lmylib.
So if Qt4 libs installed in /usr/lib and previous version of my library is there too, the application will link with old version of library what usually finishes with link failures.
Is there any way to change link order except adding
LIBS += <full_path_to/libmylib.so>
Finally I solved it with this.
LIBS += -lmylib
!greaterThan(QT_MAJOR_VERSION, 4):equals(QMAKE_LINK_SHLIB, g++)|equals(QMAKE_LINK_SHLIB, ld) {
QMAKE_LFLAGS += -L<build_dir/library_dir>
} else {
LIBS += -L<build_dir/library_dir>
}

Resources