Qt::CursorShape + QML
-
wrote on 21 Nov 2010, 20:33 last edited by
Greetings Trolls,
I would like to use the Qt enum CursorShape in my QML. Like this:
@Component.onCompleted: {
wView.setItemCursor(buttonMenuMouse, Qt.PointingHandCursor);
}@Unfortunately when trying to I get the following error:
bq. Error: Unknown method parameter type: Qt::CursorShape
Is there a way to register Qt::CursorShape in my QML context or do I have to reimplement my own enum ?
Thanks.
B.A.
-
wrote on 22 Nov 2010, 07:34 last edited by
and what exactly is a wView object? if you register it manually you could implement a member function not using Qt::CursorShape type
-
wrote on 24 Nov 2010, 09:27 last edited by
bq. if you register it manually you could implement a member function not using Qt::CursorShape type
Yes I could, but I would like to use Qt::CursorShape :).
-
wrote on 24 Nov 2010, 10:58 last edited by
Did this workaround:
@Component.onCompleted: {
wView.setItemCursor(boxMouseArea, "PointingHandCursor");
}@And in the C++:
@void WControllerView::setItemCursor(QGraphicsObject * object, const QString & shape)
{
Q_ASSERT(object);Qt::CursorShape cursor; if (shape == "PointingHandCursor") cursor = Qt::PointingHandCursor; else cursor = Qt::ArrowCursor; object->setCursor(QCursor(cursor));
}@
-
wrote on 24 Nov 2010, 15:25 last edited by
that's exactly what I meant)
-
wrote on 24 Nov 2010, 17:52 last edited by
Not very sexy but it works :).
Looks like the javascript is not a big fan of enums.
-
wrote on 24 Nov 2010, 20:05 last edited by
well that's no to so bad. you just need to register the type like other enums in QML are registered
i've searched for it in declarative sources, and what i found is that you should use Q_ENUMS macro for registering enum type
4/7