Results 1 to 3 of 3

Thread: Weird behavior of QGraphicsItem mapFromScene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2012
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Weird behavior of QGraphicsItem mapFromScene

    You usually shouldn't compare two floating numbers for equality. You say that without a transform, your code returns (0,0) but it really returns (0.0, 0.0) i.e. two floats. With a transform, it also returns two floats, and they are close to zero

    Is this really a problem, in the sense that it causes difficulties for a user? If you really need to compare the results, you should compare for equality within a small tolerance, or epsilon. This is much discussed on the web.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,329
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Weird behavior of QGraphicsItem mapFromScene

    Any coordinate that is effectively zero (and something e-15 *is* effectively zero), as bootchk points out. There are always small rounding and coordinate conversion errors when transformations are applied to floating point numbers. You're seeing one of them.

Similar Threads

  1. Weird behavior under Ubuntu Gnome
    By psih128 in forum Qt Programming
    Replies: 0
    Last Post: 6th July 2010, 14:26
  2. Replies: 1
    Last Post: 4th May 2010, 18:18
  3. Weird removeRow behavior
    By metalinspired in forum Qt Programming
    Replies: 0
    Last Post: 30th August 2009, 12:42
  4. Weird QMenu behavior on Mac
    By munna in forum Qt Programming
    Replies: 1
    Last Post: 14th January 2009, 15:18
  5. Weird behavior when readding a window to a QMdiArea
    By seand in forum Qt Programming
    Replies: 0
    Last Post: 27th August 2008, 02:14

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
  •  
Qt is a trademark of The Qt Company.