Click here to Skip to main content
15,884,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody..
I've a question about QGraphicsItem.
I've casted a qml file to QGraphicsItem (by creating a object by engine). And it's OK . But when i add this QGraphicsItem into a scene and view and i set its flag to be movable nothing will do when i try to drag it.
Here is the code:

<pre lang="c++">
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine,QUrl::fromLocalFile("qml/TabbedPage/Dial.qml"));

QObject *object = component.create();

QGraphicsItem *newItem = qobject_cast<QGraphicsItem *>(object);
newItem->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
newItem->setAcceptsHoverEvents(true);
newItem->setAcceptedMouseButtons(Qt::LeftButton);
scene.addItem(newItem);
view.setScene(&scene);
view.show();
</pre>


What's the problem? !
Posted

1 solution

I've found it!That's Not possible!! but it can be casted to QGraphicsObject
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900