Results 1 to 2 of 2

Thread: Very Strange problem

  1. #1
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Very Strange problem

    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
    Qt Code:
    1. mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent){
    2.  
    3. ((rectItem*)(mouseEvent->widget()))->set_resize_type(rectItem::vertical);
    4. setMode(Resizing);
    5.  
    6. QGraphicsScene::mousePressEvent(mouseEvent);
    7. }
    8.  
    9. mouseMoveEvent( QGraphicsSceneMouseEvent *event ) {
    10. QGraphicsScene::mouseMoveEvent(event);
    11. }
    To copy to clipboard, switch view to plain text mode 

    myrect.class
    Qt Code:
    1. mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent){
    2. if(myscene::Resizing)
    3. QGraphicsRectItem::mousePressEvent(mouseEvent);
    4. }
    5. mouseMoveEvent(QGraphicsSceneMouseEvent *event){
    6. if(myscene::Resizing)
    7. //execute the right resizing, depending on the value of type_resize
    8. ?????????????????????????????????????????
    9. Here the problem.....Why the variable type_resize(enum) has always the value of 0(the first value of the enum-->NO_RESIZE???)???????
    10. 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.....
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: Very Strange problem

    I note that the type_resize variable, has the value that i give it in the constructor......

    so if i give it the value of '0', i can modify it with the public function set_type_resize(), but then it return to '0'

    The same behaviour appears with other int value.......

    SO, IT HAS THE SAME VALUE I GIVE IT IN THE CONSTRUCTOR

    In myrect class, i implement two type of constructor:
    Qt Code:
    1. rectItem(QMenu *menu, const QRectF & rect, QGraphicsItem * parent):QGraphicsRectItem(rect,parent){}
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. rectItem(QMenu *menu, QGraphicsItem * parent):QGraphicsRectItem(parent){}
    To copy to clipboard, switch view to plain text mode 

    In these constructors i set my private int variable.......
    So, What's the matter? Perhaps some function recall the constructor for repaint the item on the scene??? ?????????

Similar Threads

  1. use Qpainter to draw lines + problem in my painter
    By ReSu in forum Qt Programming
    Replies: 4
    Last Post: 5th March 2008, 16:44
  2. Strange shortcut problem
    By blukske in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2007, 11:26
  3. Strange problem with events on Unix
    By sukanyarn in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2006, 03:45
  4. Strange Problem with JPEG Support on win XP
    By caligula in forum Installation and Deployment
    Replies: 3
    Last Post: 18th September 2006, 11:36
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.