Why can't my C++ classes use Qt? - c++

I'm working on a very basic C++ application using Qt5.6 with CMake. Git Repo Here.
My problem? My main.cpp can #include Qt classes like <QtCore/QObject>, but my defined classes cannot.
error: QtCore/QObject: No such file or directory
I have downloaded the latest version of Qt with Qt Creator here.
Could this be an improperly set up Qt environment? I don't understand how main.cpp can access Qt but my defined classes cannot.
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
project(testproject)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
############ OpenCV PACKAGE #########
set(BUILD_SHARED_LIBS ON)
set(OpenCV_FIND_QUIETLY FALSE)
find_package( OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )
# Find the QtWidgets library
find_package(Qt5Widgets)
qt5_wrap_cpp(tcp_hdr_moc ${PROJECT_SOURCE_DIR}/TcpServer.h)
# Tell CMake to create the helloworld executable
add_executable(helloworld WIN32 main.cpp
TcpServer.h TcpServer.cpp
)
# Use the Widgets module from Qt 5.
target_link_libraries(helloworld Qt5::Widgets
${OpenCV_LIBS}
${PROJECT_SOURCE_DIR}/TcpServer.cpp
${PROJECT_SOURCE_DIR}/TcpServer.h
)
main.cpp
#include <iostream>
#include <QtWidgets/QApplication>
#include <QtCore/QObject>
//#include "TcpServer.h"
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QString test = "Hello";
QObject test2;
int i = 0;
// TcpServer server;
}
User defined class: TcpServer.cpp
#include "TcpServer.h"
#include <QtNetwork/QTcpSocket>
#include <QtCore/QByteArray>
#include <QtCore/QtDebug>
#include <QtCore/QString>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
TcpServer::TcpServer(QObject *parent) :
QObject(parent)
{
server = new QTcpServer(this);
// whenever a user connects, it will emit signal
connect(server, SIGNAL(newConnection()),
this, SLOT(newConnection()));
if (!server->listen(QHostAddress::Any, 9999))
qDebug() << "Server could not start";
else
qDebug() << "Server started!";
vCapture = new VideoCapture(0);
}
void TcpServer::newConnection()
{
QTcpSocket *socket = server->nextPendingConnection();
QByteArray ContentType = ("HTTP/1.0 200 OK\r\n" \
"Cache-Control: no-cache\r\n" \
"Cache-Control: private\r\n" \
"Content-Type: multipart/x-mixed-replace;boundary=--boundary\r\n");
socket->write(ContentType);
std::vector<uchar> buff;
Mat img; //OpenCV Material
while (1) {
// Image to Byte Array via OPENCV Method
buff.clear();buff.empty();
vCapture->read(img); //Read from webcam
//TODO set the compression parameters.
imencode(".jpg", img, buff);
std::string content(buff.begin(), buff.end());
QByteArray CurrentImg(QByteArray::fromStdString(content));
QByteArray BoundaryString = ("--boundary\r\n" \
"Content-Type: image/jpeg\r\n" \
"Content-Length: ");
BoundaryString.append(QString::number(CurrentImg.length()));
BoundaryString.append("\r\n\r\n");
socket->write(BoundaryString);
socket->write(CurrentImg); // Write The Encoded Image
socket->flush();
}
}
User Defined Class Header which throws the error: TcpServer.h
#ifndef TCPSERVER_H
#define TCPSERVER_H
#include <QtCore/QObject>
#include <QtNetwork/QTcpServer>
#include "opencv2/videoio.hpp"
using namespace cv;
class TcpServer : public QObject
{
Q_OBJECT
public:
explicit TcpServer(QObject *parent = 0);
void newConnection();
private:
QTcpServer* server;
VideoCapture* vCapture;
};
#endif
For reference I am working on these two related stack overflow questions.
How to Create a HTTP MJPEG Streaming Server With QTcp-Server Sockets?
Error while using QTcpSocket.

Add find_package(Qt5Core) in addition to find_package(Qt5Widgets) and add the following lines:
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${Qt5Core_INCLUDE_DIRS})
And do not forget to add Qt5::Core to the target_link_libraries.
BTW, I see you are using QtNetwork; you will have to make the same steps for that module too. And for every other module you will use.

Related

No reply data with QNetworkAccessManager when running on another machine

I have a simple program that should retrieve the HTML from a website URL.
main.cpp
#include "Downloader.h"
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
auto dl = new Downloader(&a);
QString url = "https://www.dognow.at/ergebnisse/?page=1";
dl->fetch(url);
return a.exec();
}
Downloader.h
#ifndef DOWNLOADER_H
#define DOWNLOADER_H
#include <QNetworkReply>
#include <QObject>
class Downloader : public QObject
{
Q_OBJECT
public:
explicit Downloader(QObject* parent = nullptr);
void fetch(QString &url);
private:
QNetworkAccessManager* m_manager;
private slots:
void replyFinished(QNetworkReply* rep);
};
#endif // DOWNLOADER_H
Downloader.cpp
#include "Downloader.h"
#include <QDebug>
Downloader::Downloader(QObject* parent): QObject(parent),
m_manager(new QNetworkAccessManager(parent))
{}
void Downloader::fetch(QString& url)
{
qDebug() << "fetch " << url;
connect(m_manager, &QNetworkAccessManager::finished, this, &Downloader::replyFinished);
m_manager->get(QNetworkRequest(QUrl(url)));
}
void Downloader::replyFinished(QNetworkReply* rep)
{
QByteArray data=rep->readAll();
QString str(data);
qDebug() << "data len: " << str.length();
rep->close();
}
When I run the program on my local PC it works fine. When I run it on another machine the reply data is empty. On both systems I use Linux (x86_64) and Qt 5.15.0.
I hope someone can give me a hint where I should have a look at.
UPDATE: 2022-04-04 - 16:22:
when I run a simple curl command on the failing machine it works fine.
Ok, I found the problem.
On the failing machin I have an older ubuntu (16.04 LTS) running with an incompatible openssl version.
I found it out because I copied my own Qt libs build (debug) to the other machine and I got SSL error (incompatbile version).
I installed a newer openssl version and know it works.

Undefined references for aruco::MarkerDetector

I'm trying to get the marker position in an image, but when I compile the program, during linking, I receive several errors indicating undefined reference to Aruco (Marker.cpp:(.text+0x1643): undefined reference to 'aruco::MarkerDetector::detect(cv::Mat const&, std::vector<aruco::Marker, std::allocator<aruco::Marker> >&, cv::Mat, cv::Mat, float, bool)'), I've looked for solutions regarding linking the library but none of them seem to work. This is my CMakeList.txt:
# cmake needs this line
cmake_minimum_required(VERSION 2.8)
# Define project name
project(Pruebas_alg_new)
# Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI
find_package(OpenCV REQUIRED)
find_package(aruco)
# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " config: ${OpenCV_DIR}")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(Marker Marker.cpp)
target_link_libraries(Marker PRIVATE ${OpenCV_LIBS})
And here is the code I'm trying to compile:
#include <iostream>
#include <stdio.h>
#include <opencv2/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
#include <opencv2/imgcodecs.hpp>
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "Euler.hpp"
#include <aruco/aruco.h>
#include <aruco/markerdetector.h>
#include <aruco/marker.h>
int main(int argc, char **argv)
{
Mat img_scene = imread("/home/javier/pruebas/MasPruebas/Imagenes/Scene.jpg", IMREAD_GRAYSCALE );
if( /*!img_object.data ||*/ !img_scene.data )
{ std::cout<< " --(!) Error reading images " << std::endl;}
Mat CameraMatrix = (Mat_<double>(3,3) << 374.67,0,320.5,0,374.67,180.5,0,0,1);
aruco::MarkerDetector MDetector;
vector<aruco::Marker> Markers;
//DetectorParameters::create()
MDetector.detect(img_scene,Markers);
std::cout<< Markers.size() << std::endl;
// if at least one marker detected
for (unsigned int i = 0; i<Markers.size(); i++)
{Markers[i].draw(img_scene,cv::Scalar(0,0,255),2);}
cv::imshow("out", img_scene);
cv::waitKey(0);
return 0;
}

Qt MOC failure when building on Windows 10

I've been using PyQt for years now and had to recode a project in C++ using CLion. I have managed (after awhile) to get the code building on my MacBookPro, but when I move the project to Windows 10, all hell broke loose! I've reloaded mingw with the x86 version and gotten everything to work except MOC and AUTOUIC. The only lines I changed in the CMakeLists.txt file between Oses were the ones that pointed to the Qt install. As I said, I'm new to all this in C++ and may have some 'mistakes' in my makefile, but it works on OSX but not in Windows!
I am able to compile ui and resources files manually and get the build to compile, but I don't know how to resolve this issue.
Any help and guidance would be greatly appreciated!
====================[ Build | crapsStarter | Debug ]============================
C:\Users\a.fireheart.CLion2019.3\system\cygwin_cmake\bin\cmake.exe
--build /cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter/cmake-build-debug
--target crapsStarter -- -j 6 [ 14%] Automatic MOC for target crapsStarter
AutoMoc subprocess error
------------------------ The moc process failed to compile "/cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter/craps.h"
into
"/cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter/cmake-build-debug/crapsStarter_autogen/EWIEGA46WW/moc_craps.cpp".
Command
------- C:/Qt/5.14.1/winrt_x64_msvc2017/bin/moc.exe -I/cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter/cmake-build-debug
-I/cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter -I/cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter/cmake-build-debug/crapsStarter_autogen/include
-IC:/Qt/5.14.1/winrt_x64_msvc2017/include -IC:/Qt/5.14.1/winrt_x64_msvc2017/include/QtCore -IC:/Qt/5.14.1/winrt_x64_msvc2017/./mkspecs/winrt-x64-msvc2017 -IC:/Qt/5.14.1/winrt_x64_msvc2017/include/QtGui -IC:/Qt/5.14.1/winrt_x64_msvc2017/include/QtANGLE -IC:/Qt/5.14.1/winrt_x64_msvc2017/include/QtWidgets -I/usr/lib/gcc/x86_64-pc-cygwin/9.2.0/include/c++ -I/usr/lib/gcc/x86_64-pc-cygwin/9.2.0/include/c++/x86_64-pc-cygwin -I/usr/lib/gcc/x86_64-pc-cygwin/9.2.0/include/c++/backward -I/usr/lib/gcc/x86_64-pc-cygwin/9.2.0/include -I/usr/include -I/usr/include/w32api -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB --include /cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter/cmake-build-debug/crapsStarter_autogen/moc_predefs.h
-o /cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter/cmake-build-debug/crapsStarter_autogen/EWIEGA46WW/moc_craps.cpp
/cygdrive/c/Users/a.fireheart/CLionProjects/crapsStarter/craps.h
Output
make[3]: * [CMakeFiles/crapsStarter_autogen.dir/build.make:58:
CMakeFiles/crapsStarter_autogen] Error 1 make[2]:
[CMakeFiles/Makefile2:104: CMakeFiles/crapsStarter_autogen.dir/all]
Error 2 make[1]: [CMakeFiles/Makefile2:84:
CMakeFiles/crapsStarter.dir/rule] Error 2 make: * [Makefile:118:
crapsStarter] Error 2
***************** My CMakeLists.txt file content *******************************
cmake_minimum_required(VERSION 3.15)
project(crapsStarter)
set(CMAKE_CXX_STANDARD 17)
#set(RESOURCES crapsResources.qrc)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set(CMAKE_AUTOUIC ON)
include_directories(cmake-build-debug/crapsStarter_autogen/include)
# Tell cmake where Qt is located
set(Qt5_DIR "C:/Qt/5.14.1/winrt_x64_msvc2017/lib/cmake/Qt5")
set(QT_INCLUDES "C:/Qt/5.14.1/winrt_x64_msvc2017/include")
MESSAGE("QT_INCLUDES: ${QT_INCLUDES}")
# Include a library search using find_package()
# via REQUIRED, specify that libraries are required
set(Qt5 NEED)
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
set(SOURCE_FILES craps.cpp die.cpp crapsGame.cpp crapsResources.cpp)
add_executable(crapsStarter ${SOURCE_FILES})
# specify which libraries to connect
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
craps.h
//
// Created by Arana Fireheart on 2/2/20.
//
#ifndef CRAPSSTARTER_CRAPS_H
#define CRAPSSTARTER_CRAPS_H
#include "ui_CrapsMainWindow.h"
#include "die.h"
#include <QMainWindow>
class CrapsMainWindow : public QMainWindow, private Ui::CrapsMainWindow {
Q_OBJECT
public:
CrapsMainWindow(QMainWindow *parent = nullptr);
void printStringRep();
void updateUI();
private:
Die die1, die2;
bool firstRoll = true;
int winsCount = 0;
public Q_SLOTS:
void rollButtonClickedHandler();
};
#include "moc_craps.cpp"
#endif //CRAPSSTARTER_CRAPS_H
craps.cpp
#include <iostream>
#include <stdio.h>
//#include <QApplication>
//#include <QWidget>
//#include <QGridLayout>
//#include <QPushButton>
//#include <QLabel>
//#include <QPixmap>
#include "die.h"
#include "craps.h"
#include "ui_CrapsMainWindow.h"
CrapsMainWindow :: CrapsMainWindow(QMainWindow *parent) {
// Build a GUI window with two dice.
setupUi(this);
Die die1, die2;
bool firstRoll = true;
int winsCount = 0;
QObject::connect(rollButton, SIGNAL(clicked()), this, SLOT(rollButtonClickedHandler()));
}
void CrapsMainWindow::printStringRep() {
// String representation for Craps.
char buffer[25];
int length = sprintf(buffer, "Die1: %i\nDie2: %i\n", die1.getValue(), die2.getValue());
printf("%s", buffer);
}
void CrapsMainWindow::updateUI() {
// printf("Inside updateUI()\n");
std::string die1ImageName = ":/dieImages/" + std::to_string(die1.getValue());
std::string die2ImageName = ":/dieImages/" + std::to_string(die2.getValue());
die1UI->setPixmap(QPixmap(QString::fromStdString(die1ImageName)));
die2UI->setPixmap(QPixmap(QString::fromStdString(die2ImageName)));
currentBankValueUI->setText(QString::fromStdString("100"));
}
// Player asked for another roll of the dice.
void CrapsMainWindow::rollButtonClickedHandler() {
//void Craps::rollButtonClickedHandler() {
printf("Roll button clicked\n");
die1.roll();
die2.roll();
printStringRep();
updateUI();
}

How to disable OpenSSL in QNetworkAccessManager?

I am working with Qt 5.2. I am using QNetworkAccessManager to make some posts to a web (without encryption). Now I have to verify a signature of message (That message has nothing to do with the post and QNetworkAccessManager, they are completly separated).
Both parts of code work fine separately, but when they come together the application crashes. If I add the OpenSSL to the application and I call a QNetworkAccessManager::post then it fails. The program pointer is in OPENSSL_sk_pop_free and it crashes after a QNetworkAccessManager::post call.
The code:
//#define OPENSSL
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <openssl/bio.h>
#if defined(OPENSSL)
#define USE_SHA1
bool validateLicense()
{
BIO* bio = BIO_new(BIO_s_mem());
BIO_free(bio);
return true;
}
#endif
int main() {
QNetworkAccessManager* manager = new QNetworkAccessManager();
QNetworkRequest request;
request.setUrl(QUrl("http:\\192.168.0.1"));
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
QString com("{\"hello world\"}");
QByteArray data(com.toLocal8Bit());
qDebug() << Q_FUNC_INFO << "data to POST" << com;
manager->post(request, data);
#if defined(OPENSSL)
validateLicense();
#endif
}
The .pro file:
QT += core network
QT -= gui
CONFIG += c++11
TARGET = console
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
#
# libcrypto
#
LIBS += $$[OPENSSL_INSTALL_ROOT]/libcrypto.a
If I uncomment the #define OPENSSL the application crashes in line manager->post(request, data);.
How can I disable the OpenSSL in QNetworkAccessManager to avoid the application crash?

Qt C++ signals and slots did not fire

I have programmed Qt a couple of times already and I really like the signals and slots feature. But now, I guess I'm having a problem when a signal is emitted from one thread, the corresponding slot from another thread is not fired. The connection was made in the main program.
This is also my first time to use Qt for ROS which uses CMake. The signal fired by the QThread triggered their corresponding slots but the emitted signal of my class UserInput did not trigger the slot in tflistener where it supposed to. I have tried everything I can. Any help? The code is provided below.
Main.cpp
#include <QCoreApplication>
#include <QThread>
#include "userinput.h"
#include "tfcompleter.h"
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
QThread *thread1 = new QThread();
QThread *thread2 = new QThread();
UserInput *input1 = new UserInput();
TfCompleter *completer = new TfCompleter();
QObject::connect(input1, SIGNAL(togglePause2()), completer, SLOT(toggle()));
QObject::connect(thread1, SIGNAL(started()), completer, SLOT(startCounting()));
QObject::connect(thread2, SIGNAL(started()), input1, SLOT(start()));
completer->moveToThread(thread1);
input1->moveToThread(thread2);
thread1->start();
thread2->start();
app.exec();
return 0;
}
What I want to do is.. There are two seperate threads. One thread is for the user input. When the user enters [space], the thread emits a signal to toggle the boolean member field of the other thread. The other thread 's task is to just continue its process if the user wants it to run, otherwise, the user does not want it to run. I wanted to grant the user to toggle the processing anytime that he wants, that's why I decided to bring them into seperate threads.
The following codes are the tflistener and userinput.
tfcompleter.h
#ifndef TFCOMPLETER_H
#define TFCOMPLETER_H
#include <QObject>
#include <QtCore>
class TfCompleter : public QObject
{
Q_OBJECT
private:
bool isCount;
public Q_SLOTS:
void toggle();
void startCounting();
};
#endif
tflistener.cpp
#include "tfcompleter.h"
#include <iostream>
void TfCompleter::startCounting()
{
static uint i = 0;
while(true)
{
if(isCount)
std::cout << i++ << std::endl;
}
}
void TfCompleter::toggle()
{
// isCount = ~isCount;
std::cout << "isCount " << std::endl;
}
UserInput.h
#ifndef USERINPUT_H
#define USERINPUT_H
#include <QObject>
#include <QtCore>
class UserInput : public QObject
{
Q_OBJECT
public Q_SLOTS:
void start(); // Waits for the keypress from the user and emits the corresponding signal.
public:
Q_SIGNALS:
void togglePause2();
};
#endif
UserInput.cpp
#include "userinput.h"
#include <iostream>
#include <cstdio>
// Implementation of getch
#include <termios.h>
#include <unistd.h>
/* reads from keypress, doesn't echo */
int getch(void)
{
struct termios oldattr, newattr;
int ch;
tcgetattr( STDIN_FILENO, &oldattr );
newattr = oldattr;
newattr.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newattr );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldattr );
return ch;
}
void UserInput::start()
{
char c = 0;
while (true)
{
c = getch();
if (c == ' ')
{
Q_EMIT togglePause2();
std::cout << "SPACE" << std::endl;
}
c = 0;
}
}
Here is the CMakeLists.txt. I just placed it here also since I don't know maybe the CMake has also a factor here.
CMakeLists.txt
##############################################################################
# CMake
##############################################################################
cmake_minimum_required(VERSION 2.4.6)
##############################################################################
# Ros Initialisation
##############################################################################
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
set(CMAKE_AUTOMOC ON)
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE Debug)
##############################################################################
# Qt Environment
##############################################################################
# Could use this, but qt-ros would need an updated deb, instead we'll move to catkin
# rosbuild_include(qt_build qt-ros)
rosbuild_find_ros_package(qt_build)
include(${qt_build_PACKAGE_PATH}/qt-ros.cmake)
rosbuild_prepare_qt4(QtCore) # Add the appropriate components to the component list here
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
##############################################################################
# Sections
##############################################################################
#file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
#file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/rgbdslam_client/*.hpp)
#QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
#QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})
##############################################################################
# Sources
##############################################################################
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
##############################################################################
# Binaries
##############################################################################
rosbuild_add_executable(rgbdslam_client ${QT_SOURCES} ${QT_MOC_HPP})
#rosbuild_add_executable(rgbdslam_client ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
target_link_libraries(rgbdslam_client ${QT_LIBRARIES})
It is hard to find bug from your posted code. I just want to point out one issue:
You are first making the connection and then moving the objects to new threads. Since they were created in same thread they had same Thread Affinity. So by default the connection type will be direct, which means, the slot will be executed from the same thread from which signal is emitted.
But after moving to new threads, thread affinity for both objects gets changed. Although you did not say how you could find out it is not working, I recommend to look at this matter. If you expect the slot to be executed in different thread, and tested that way, then you may not get desired output and think it is not working.
When signal and slot are meant to be executed in different thread, it is better to connect them after moving the corresponding objects to new threads. Qt::AutoConnection will by default use Qt::QueuedConnection when objects are in different thread.