#include "mainwindow.h"
#include <QtGui/QApplication>
#include <QAccelerometer>
int main(int argc, char *argv[])
{
MainWindow mainWindow;
mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
mainWindow.showExpanded();
// On the heap (deleted when this object is deleted)
QAccelerometer *sensor = new QAccelerometer(this);
// On the stack (deleted when the current scope ends)
QOrientationSensor orient_sensor;
// start the sensor
QSensor sensor("QAccelerometer");
sensor.start();
// later
QSensorReading *reading = sensor.reading();
qreal x = reading->property("x").value<qreal>();
qreal y = reading->value(1).value<qreal>();
QAccelerometer sensor;
sensor.setProperty("maximumReadingCount", 100);
sensor.setProperty("processAllReadings", true);
return app.exec();
}
#include "mainwindow.h"
#include <QtGui/QApplication>
#include <QAccelerometer>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow mainWindow;
mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
mainWindow.showExpanded();
// On the heap (deleted when this object is deleted)
QAccelerometer *sensor = new QAccelerometer(this);
// On the stack (deleted when the current scope ends)
QOrientationSensor orient_sensor;
// start the sensor
QSensor sensor("QAccelerometer");
sensor.start();
// later
QSensorReading *reading = sensor.reading();
qreal x = reading->property("x").value<qreal>();
qreal y = reading->value(1).value<qreal>();
QAccelerometer sensor;
sensor.setProperty("maximumReadingCount", 100);
sensor.setProperty("processAllReadings", true);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
With using this code which I written basing on the codes from your site I still receive compilation errors. For example
C:\...\main.cpp:5: error: QAccelerometer: No such file or directory
Or
C:\...\main.cpp:16: error: 'QAccelerometer' was not declared in this scope
or
C:\...\main.cpp:16: error: expected type-specifier before 'QAccelerometer'
How to repair this?
Bookmarks