How use Point Cloud Library (PCL) in Qt creator? - qt

As part as a master project, I need to create a post-processing app for a 3D scan.
I discovered PCL and I managed to use it on MSVC 2015 and performed few operations with sucess without any GUI.
Now I would like to use PCL with Qt creator.
(like in http://pointclouds.org/documentation/tutorials/qt_visualizer.php).
I am a noob with Qt and I don't know how to include PCL in a project.
If anybody can help me by giving me an orientation on setting up that kind of project, or a property sheet, It'll be great,
I'm working on Windows 7 , 64 bits.

To import a libary (dll) into your Qt project, simply right-click on your Qt solution, choose "Add libary", then extern libary and add the libary path and the include path. This will make the header files accessable for the IDE.
Now you can code!

Related

Add MFC to Qt Creator (QMake) project

I need to add some huge classes (non-GUI) that use CString, CArray etc. to my Qt project on Windows, but I am not sure how to use MFC outside of Visual Studio, via Qt Creator QMake (with VS 2017 compiler).
What libraries do I need to link for that?
I found some examples for CMake that use built-in CMAKE_MFC_FLAG but not much information about QMake.

How to use offline mapbox for my specific qml application?

I cloned mapboxgl from Github. I followed the steps.
https://github.com/mapbox/mapbox-gl-native/tree/master/platform/qt
The map running when I enter the make run-qt-app command on mapbox-gl-native directory. But I would like to include the offline map on my qml application to implement via qt creator.
How can I do it? Could you help me?
That repository contains code for the Qt bindings and should not be used directly.
Use the "mapboxgl" plugin available since Qt 5.9. There you can specify the path for the offline database:
https://doc-snapshots.qt.io/qt5-5.9/location-plugin-mapboxgl.html#optional-plugin-parameters

QT5.0.2 project needs more DLLs than QT4.8

Recently we moved to QT 5.0.2 from QT4.8. Our project now needs more DLL files than the earlier. It requires qml, opengl, printer modules. However we did not use any of these modules in our application. The size of exe file increased due to additional DLLs.
QT-= qml opengl -> did not exclude this module from our application.
Are these additional DLLs are compulsory for Qt 5.0.2 ? Is there any way to come out from this? We need to exclude these dlls to reduce exe size.
Some of the modules you use may be dependent on those you don't, which means your project depends on them indirectly. For example, by default, some modules (QtWebKit, QtMultimedia) utilize ANGLE which uses OpenGL. You can try to trace those dependencies by using a program named Dependency Walker (available here). The Qt GUI has changed a lot since 4.8, and there are now separate modules for printing and other functions (see here).
Sources:
Qt 5 on Windows ANGLE and OpenGL
Qt 5 Deployment on Windows
By the way, someone has (had) a similar problem: http://www.qtcentre.org/archive/index.php/t-52102.html. (Unfortunately, there is no solution in that link.)
It turned out that this is actually a bug in Qt.

Embedding PCL Viewer on a Qt GUI Main Window

I am trying to develop a user interface using QtCreator on a Windows 7 64-bit machine. This user interface will be deployed on a 32-bit Windows 7 machine, and will control a projector and a camera for a structured-light application. For reasons beyond my control (compatibility with camera and projector's APIs), I will use the MS VS 2010 32bit compiler for this. After a couple of weeks trying to have everything I need working together (Qt 4.8.4, QtCreator and Point Cloud Library), I am now facing a slight problem.
Is there a way that I can embed the PCL Point Cloud Viewer inside my main Qt GUI window? The problem is that when I use the PCL viewer, it brings up a separate window. I want this window to be embedded inside my main window, and I want to still be able to interact with it (rotate, pan, zoom, etc.).
As you may be able to tell from my post, I am a newbie on Qt/PCL/etc., so any example with minimal code to do this would be greatly appreciated. I have done weeks of research on this and I have not been able to find a solution, although I get the impression that a Qt Widget might be the way to go.
You can simply use PCL's PCLVisualizer, which is extensively described here, via the QVTKWidget. This is the setup I'm currently running. So you would end up doing something along the lines of the following (pseudo-)code:
In your header:
class PointCloudWidget : public QVTKWidget
{
//Whatever comes before (constructor, methods, etc.)
private:
pcl::visualization::PCLVisualizer m_visualizer;
};
And in your cpp:
PointCloudWidget::PointCloudWidget(QWidget *parent) : QVTKWidget(parent)
{
this->SetRenderWindow(m_visualizer.getRenderWindow());
}
You can then use the visualizer to achieve the same functionality as the PCL viewer has.
Look at the kind of minimal code I put here (PCL Viewer with Qt GUI minimal code).
There are some redundancies, but the code I believe is pretty straightforward.
The main idea is to put the files in the one folder and start project from CMakeLists.txt (Qt cmake wizard).
I use build directory inside project dir. (this is important, because in pclwindow.cpp I hardcoded the path to the generated file #include "build/ui_pclwindow.h"
If app builds, but crashes you'll probably need to add some dependencies (e.g. dll files on Win platform)
I hope it will give you fast and simple start!

Compiled distribution of Qt application for windows

I was successfully able to compile and run my Qt application. However, when I move the .exe file outside its original path, I found out that I have to manually copy the Qt DLLs (e.g. mingw10.dll, qtcore4.dll). Is there any dynamic way to link these libraries with my application?
I think you mean you want to "statically" link these libraries with your application.
Basically this means that everything will be rolled inside your exe, and you will have no need of those dlls anymore.
There are advantages to to static linking, but there are also disadvantages as well. You should be absolutely sure that this is what you want to do before you go this way.
Check out this link which explains the difference in depth Dynamic Linking vs Static Linking
As for your specific issue, if you are sure you want to use static linking you will have to change your Qt setup to be built statically. By default the Qt distribution is setup to use dynamic linking. There is a handy guide for that here.
Basically when you setup the build you have to run "configure -static" to change all the project settings to use static linking instead of dynamic linking. And then build Qt over again.
You should also verify your Qt license. If you are using the Qt LGPL license and you want to to link statically you will have to include all your object files (.o and .obj) as Mihai Limbășan wisely explained in his comment. If you have bought and paid for Qt, then you have no problem.
If the DLLs are on the PATH for the application, then they will be found and work. So, you could add where your Qt binaries/dlls are into the %PATH% environment variable. If you're going to create an installer for your application, you'll need to either package these libraries in so they're in the bin directory - or you'll have to expect every user to install and possibly compile Qt themselves (hint: go with the first option. :) )

Resources