Hi all,
I am playing with LeapMotion, trying to compile Sample file in QT, but I had some errors. So I tried with a simpler file.
Here the cpp file:
include
include
include "leap.h"
class MyListener : public QObject, public Leap::Listener {
public:
virtual void onFrame(const Leap::Controller & ctl) {
Leap::Frame f = ctl.frame();
// This is a hack so that we avoid having to declare a signal and
// use moc generated code.
setObjectName(QString::number(f.id()));
// emits objectNameChanged(QString)
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyListener listener;
Leap::Controller controller;
controller.addListener(listener);
QLabel frameLabel;
frameLabel.setMinimumSize(200, 50);
frameLabel.show();
frameLabel.connect(&listener, SIGNAL(objectNameChanged(QString)),
SLOT(setText(QString)));
int rc = a.exec();
controller.removeListener(listener);
return rc;
}
Here the pro file:
QT += core
QT -= gui
QT += widgets
CONFIG += c++11
TARGET = LeapMotion
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
The following define makes your compiler emit warnings if you use
any feature of Qt which as been marked 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
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
HEADERS += \
Leap.h \
LeapC.h \
LeapMath.h
win32: LIBS += -L$$PWD/lib/x86/ -lLeap
INCLUDEPATH += $$PWD/lib/x86
DEPENDPATH += $$PWD/lib/x86
The errors are something like this:
C:....main.cpp:20: error: undefined reference to `Leap::Controller::Controller()'
I think that it is related to library link in pro file but I don't know how to set it correctly.
Thanks in advance