It is a whole day, that i try to resolve this problem.
In a few words:
I have myscene class (custom QGraphicsScene), myview class(custom QGraphicsView) and myrect(custom QgraphicsRectItem).........
I insert myrect into myscene and i can move and select it without any problem.
Now i'm trying to implement the resize behaviour of myrect.
so, i introduce in my implementation a variabile of type enum that set the modality of my scene(enum type{MoveItem,Resizing}...for example.....
i also have a variable(enum type_resize) in myrect class, that set the kind of resize(NO_RESIZE, horizzontal, vertical, .......)
my example code:
myscene.class
((rectItem*)(mouseEvent->widget()))->set_resize_type(rectItem::vertical);
setMode(Resizing);
}
}
mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent){
((rectItem*)(mouseEvent->widget()))->set_resize_type(rectItem::vertical);
setMode(Resizing);
QGraphicsScene::mousePressEvent(mouseEvent);
}
mouseMoveEvent( QGraphicsSceneMouseEvent *event ) {
QGraphicsScene::mouseMoveEvent(event);
}
To copy to clipboard, switch view to plain text mode
myrect.class
if(myscene::Resizing)
}
if(myscene::Resizing)
//execute the right resizing, depending on the value of type_resize
?????????????????????????????????????????
Here the problem.....Why the variable type_resize(enum) has always the value of 0(the first value of the enum-->NO_RESIZE???)???????
A wrote some printf for debugging, and i saw that 1 step before the type_resize has the "right" value, but when i print it in the mouseMoveEvent of myrect it change it's value.......Who change this value??Perhaps some spirit.....
}
mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent){
if(myscene::Resizing)
QGraphicsRectItem::mousePressEvent(mouseEvent);
}
mouseMoveEvent(QGraphicsSceneMouseEvent *event){
if(myscene::Resizing)
//execute the right resizing, depending on the value of type_resize
?????????????????????????????????????????
Here the problem.....Why the variable type_resize(enum) has always the value of 0(the first value of the enum-->NO_RESIZE???)???????
A wrote some printf for debugging, and i saw that 1 step before the type_resize has the "right" value, but when i print it in the mouseMoveEvent of myrect it change it's value.......Who change this value??Perhaps some spirit.....
}
To copy to clipboard, switch view to plain text mode
Bookmarks