Extending QDeclarativeView for adding orientation sensor
-
Hey guys. 1st of all, I have to warn you I've started learning Qt (and C++) like... yesterday, so... please don't laugh too much on my bableing.
I'm trying to extend QDeclarativeView class, in order to add an orientation sensor through its constructor, and not via code in some other zone of my application.
I've found this link, telling me how to create an orientation sensor: http://www.developer.nokia.com/Community/Wiki/Implementing_custom_orientation_changes_animation_with_QML
and I'm trying to implement it smth like this:
H File
@#ifndef HDECLARATIVEVIEW_H
#define HDECLARATIVEVIEW_H#include <QDeclarativeView>
#include <QOrientationSensor>
#include <QUrl>#include "horientationfilter.h"
class Q_DECLARATIVE_EXPORT HDeclarativeView : public QDeclarativeView
{
Q_OBJECTpublic:
explicit HDeclarativeView(QWidget *parent = 0);
// HDeclarativeView(const QUrl &source, QWidget *parent = 0);
virtual ~HDeclarativeView();private:
int initOrientationSensor();
};#endif // HDECLARATIVEVIEW_H@
CPP File
@#include "hdeclarativeview.h"#include <QObject>
HDeclarativeView::HDeclarativeView(QWidget *parent) :
QDeclarativeView(parent)
{
this->initOrientationSensor();
}//HDeclarativeView::HDeclarativeView(const QUrl &source, QWidget *parent = 0) :
// QDeclarativeView(source, parent)
//{//}
HDeclarativeView::~HDeclarativeView()
{}
int HDeclarativeView::initOrientationSensor()
{
QOrientationSensor sensor;
HOrientationFilter filter;
sensor.addFilter(&filter);// Connect the Qt signal to QML function QObject::connect( &filter, SIGNAL(orientationChanged(const QVariant&)), this->rootObject(), SLOT(orientationChanged(const QVariant&)), Qt::AutoConnection ); sensor.start(); return 0;
}@
The errors I get looks like this:
~/.../hdeclarativeview.cpp:8: error: no matching function for call to ‘HDeclarativeView::initOrientationSensor(HDeclarativeView* const)’
and it's listing me the ways QObject::connect() can be called further.
As my days with C/C++ were long long over until this project came up, I'm asking you for help, and will probably bug you pretty often with new and new dumm questions.
Anyone care to be my mentor?