hi everyone,
I am using qt android 5.1.1
and I have problem even I add sensors to pro file what is problem.
Thank you for any comment.
problem is :
../sensor_test/mainwindow.cpp:9: error: undefined reference to 'QAccelerometer::QAccelerometer(QObject*)'
../sensor_test/mainwindow.cpp:19: error: undefined reference to 'QSensor::QSensor(QByteArray const&, QObject*)'
../sensor_test/mainwindow.cpp:20: error: undefined reference to 'QSensor::start()'
../sensor_test/mainwindow.cpp:21: error: undefined reference to 'QSensor::reading() const'
Makefile:146: recipe for target 'libsensor_test.so' failed
../sensor_test/mainwindow.cpp:22: error: undefined reference to 'QSensor::~QSensor()'
../sensor_test/mainwindow.cpp:22: error: undefined reference to 'QSensor::~QSensor()'
collect2.exe: error: ld returned 1 exit status
my profile:
#-------------------------------------------------
#
# Project created by QtCreator 2013-08-30T14:44:53
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = sensor_test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
CONFIG += mobility
MOBILITY += sensors
OTHER_FILES += \
android/AndroidManifest.xml \
android/res/layout/splash.xml \
android/res/values/libs.xml \
android/res/values/strings.xml \
android/res/values-de/strings.xml \
android/res/values-el/strings.xml \
android/res/values-es/strings.xml \
android/res/values-et/strings.xml \
android/res/values-fa/strings.xml \
android/res/values-fr/strings.xml \
android/res/values-id/strings.xml \
android/res/values-it/strings.xml \
android/res/values-ja/strings.xml \
android/res/values-ms/strings.xml \
android/res/values-nb/strings.xml \
android/res/values-nl/strings.xml \
android/res/values-pl/strings.xml \
android/res/values-pt-rBR/strings.xml \
android/res/values-ro/strings.xml \
android/res/values-rs/strings.xml \
android/res/values-ru/strings.xml \
android/res/values-zh-rCN/strings.xml \
android/res/values-zh-rTW/strings.xml \
android/src/org/kde/necessitas/ministro/IMinistro.aidl \
android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl \
android/src/org/qtproject/qt5/android/bindings/QtActivity.java \
android/src/org/qtproject/qt5/android/bindings/QtApplication.java \
android/version.xml
#-------------------------------------------------
#
# Project created by QtCreator 2013-08-30T14:44:53
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = sensor_test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
CONFIG += mobility
MOBILITY += sensors
OTHER_FILES += \
android/AndroidManifest.xml \
android/res/layout/splash.xml \
android/res/values/libs.xml \
android/res/values/strings.xml \
android/res/values-de/strings.xml \
android/res/values-el/strings.xml \
android/res/values-es/strings.xml \
android/res/values-et/strings.xml \
android/res/values-fa/strings.xml \
android/res/values-fr/strings.xml \
android/res/values-id/strings.xml \
android/res/values-it/strings.xml \
android/res/values-ja/strings.xml \
android/res/values-ms/strings.xml \
android/res/values-nb/strings.xml \
android/res/values-nl/strings.xml \
android/res/values-pl/strings.xml \
android/res/values-pt-rBR/strings.xml \
android/res/values-ro/strings.xml \
android/res/values-rs/strings.xml \
android/res/values-ru/strings.xml \
android/res/values-zh-rCN/strings.xml \
android/res/values-zh-rTW/strings.xml \
android/src/org/kde/necessitas/ministro/IMinistro.aidl \
android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl \
android/src/org/qtproject/qt5/android/bindings/QtActivity.java \
android/src/org/qtproject/qt5/android/bindings/QtApplication.java \
android/version.xml
To copy to clipboard, switch view to plain text mode
and my code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ac=new QAccelerometer(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QSensor sensor("QAccelerometer");
sensor.start();
QSensorReading *read=sensor.reading();
ui->lineEdit->setText(read->property("x").value<QString>());
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ac=new QAccelerometer(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QSensor sensor("QAccelerometer");
sensor.start();
QSensorReading *read=sensor.reading();
ui->lineEdit->setText(read->property("x").value<QString>());
}
To copy to clipboard, switch view to plain text mode
Bookmarks