Mouse cursor shape
-
Check this link "MouseArea Element Reference":http://qt-project.org/doc/qt-4.7/qml-mousearea.html U'll get an idea about it.
Note: Check the Doc Notes in it.
-
OK, I have following errors:
@../supertest/main.cpp: In function 'int main(int, char**)':
../supertest/main.cpp:9:21: error: 'CursorShapeArea' was not declared in this scope
../supertest/main.cpp:9:72: error: no matching function for call to 'qmlRegisterType(const char [8], int, int, const char [16])'
../supertest/main.cpp:9:72: note: candidates are:
/usr/include/qt4/QtDeclarative/qdeclarative.h:90:5: note: template<class T> int qmlRegisterType()
/usr/include/qt4/QtDeclarative/qdeclarative.h:160:5: note: template<class T> int qmlRegisterType(const char*, int, int, const char*)
/usr/include/qt4/QtDeclarative/qdeclarative.h:194:5: note: template<class T, int metaObjectRevision> int qmlRegisterType(const char*, int, int, const char*)@My cursorshapearea.cpp file:
@
#include "cursorshapearea.h"QsltCursorShapeArea::QsltCursorShapeArea(QDeclarativeItem *parent) :
QDeclarativeItem(parent),
m_currentShape(-1)
{
}Qt::CursorShape QsltCursorShapeArea::cursorShape() const
{
return cursor().shape();
}void QsltCursorShapeArea::setCursorShape(Qt::CursorShape cursorShape)
{
if (m_currentShape == (int) cursorShape)
return;setCursor(cursorShape);
emit cursorShapeChanged();m_currentShape = cursorShape;
}@My cursorshapearea.h file:
@#ifndef CURSORSHAPEAREA_H
#define CURSORSHAPEAREA_H#include <QDeclarativeItem>
class QsltCursorShapeArea : public QDeclarativeItem
{
Q_OBJECTQ_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape NOTIFY cursorShapeChanged)
public:
explicit QsltCursorShapeArea(QDeclarativeItem *parent = 0);
Qt::CursorShape cursorShape() const;
Q_INVOKABLE void setCursorShape(Qt::CursorShape cursorShape);private:
int m_currentShape;signals:
void cursorShapeChanged();
};#endif // CURSORSHAPEAREA_H
@main.cpp file:
@#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include <QtDeclarative>
#include "cursorshapearea.h"Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
qmlRegisterType<CursorShapeArea>("MyTools", 1, 0, "CursorShapeArea");
QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setMainQmlFile(QLatin1String("qml/supertest/main.qml"));
viewer.showExpanded();return app->exec();
}
@main.qml file:
@// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import MyTools 1.0
Rectangle {
width: 360
height: 360
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
@