Results 1 to 6 of 6

Thread: Warning: Calling move() inside moveEvent() can lead to infinite recursion

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Question Warning: Calling move() inside moveEvent() can lead to infinite recursion

    hi
    i have a qlabel which has to be moved when the mouse receives the mouse move event.

    but the documentation warns like this

    Warning: Calling move() or setGeometry() inside moveEvent() can lead to infinite recursion.


    Then how to achieve movement of a widget

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Warning: Calling move() inside moveEvent() can lead to infinite recursion

    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    bkastel1 (20th November 2007)

  4. #3
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Question Re: Warning: Calling move() inside moveEvent() can lead to infinite recursion

    thanks
    but the t QWidget::mouseMoveEvent does not perform as expected.

    here is the code, i dont know what is the bug in it

    Qt Code:
    1. void IV_label::mouseMoveEvent ( QMouseEvent * event )
    2. {
    3. //the distance moved by mouse is mapped to top left of widget
    4. this->move(mapToGlobal(event->pos()) - this->mapToGlobal(this->pos()));
    5. }
    To copy to clipboard, switch view to plain text mode 

    the widget(label) moves and becomes invisble

    i want to move a label using mouse

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Warning: Calling move() inside moveEvent() can lead to infinite recursion

    Well actually, it's you who moves the label widget to a non-sense location. Would you mind taking a look at the wiki article I gave link to?
    J-P Nurmi

  6. #5
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: Warning: Calling move() inside moveEvent() can lead to infinite recursion

    i read the article and it works because it takes the reference coordinate of its parents(
    else
    move(mapToParent(event->pos() - offset));
    )

    but i have a qscrollarea as my labels parent so i am going for global referencing.

    cant we use move function for positioning the child widgets using global reference system.

  7. #6
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: Warning: Calling move() inside moveEvent() can lead to infinite recursion

    oh thanks it works actually there was a mix between the global and parent coordinates.

Similar Threads

  1. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 15:18
  2. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 06:23

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.