When I was add "item->setFlags(QGraphicsItem::ItemIsMovable);" in menumanager.cpp
First, One can move to what the mouse move.But second time to move the item,it will jump to the Original pos of first time.
What the problem is ?
When I was add "item->setFlags(QGraphicsItem::ItemIsMovable);" in menumanager.cpp
First, One can move to what the mouse move.But second time to move the item,it will jump to the Original pos of first time.
What the problem is ?
Last edited by yzdying; 19th February 2011 at 04:33. Reason: updated contents
Nobody know?
Speaking only for me, I just don't understand what you wrote.
Try to explain more in details, and add code.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
yzdying (22nd February 2011)
Think you high_flyer, My English is no good,
I would like to use MouseMoveEvent event of Textbutton, so that I can drag the item to the specified location.
I add the flag "QGraphicsItem::ItemIsMovable" to item in menumanager.cpp
First, Drag a item to specified location . When I click the leftbutton and start to drag the item,it will jump to (0 ,0) before the mouse moving.Qt Code:
{ ......... // create normal menu button item = new TextButton(label, TextButton::LEFT, type, this->window->scene, this->window->mainSceneRoot); currentNode = currentNode.nextSibling(); ......... }To copy to clipboard, switch view to plain text mode
I drag dowm a item from the location of (59, 233) to the specified location of (59, 236);
drag item pos output:
QPointF(59, 233)
QPointF(0, 1)
QPointF(0, 2)
QPointF(0, 3)
As you can see, the moving graber jump from (59, 233) to (0, 1).
So I don't know what cause this result.
You can have a try to drag.
Last edited by yzdying; 22nd February 2011 at 02:51.
Please provide the code that deals with the moving, and setting of coordinates.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Only to add the pos output. and Nothing modited to the qtdemo source besides added the ItemIsMovoble flag;Qt Code:
{ qDebug() << pos(); }To copy to clipboard, switch view to plain text mode
the moving graber is in scene coordinates
Last edited by high_flyer; 22nd February 2011 at 14:23. Reason: code tags
But where is the code that sets the position in your code?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
yzdying (23rd February 2011)
Thanks again!
Qt Code:
//TextButton.cpp { qDebug() << pos(); }To copy to clipboard, switch view to plain text modeQt Code:
menumanager.cpp { ......... // create normal menu button item = new TextButton(label, TextButton::LEFT, type, this->window->scene, this->window->mainSceneRoot); currentNode = currentNode.nextSibling(); ......... }To copy to clipboard, switch view to plain text mode
Only modified two places in the source of qtdemo.
But course that the moving item jump from (59, 233) to (0, 1) in the procedure of qtdemo.
Bookmarks