Results 1 to 3 of 3

Thread: mapToScene, mapToItem doesn't work for child item after first draw (Qt 4.7)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default mapToScene, mapToItem doesn't work for child item after first draw (Qt 4.7)

    In my main project I met problem. I created scene with items and they had subitems. I need map subitems points to scene and parent items coordinates. But this didn't work after first draw. After research I found inside Qt - the value of QTransform::m_dirty property remains 0 after child item was bond to parent item and all drawn. In this case mapToItem( parentItem(), QPointF(...) ) returned same QPointF(...) as parameter given. Almost same happened after call to mapToScene( QPointF(...) ) - it returned not scene coordinates but local QPointF(...) instead. That was most strange - after some user actions around scene f.e. drag-n-drop to scene, or opening modal window - all began work properly. But I was unhappy trying simulate this from code.

    To work around this problem I created simple project. It's structure is very similar to my main project. It creates scene, item on it and adds subitem to item. Entire way is the same as I have in main project. And this test project gives same result as my main project - Subitem::mapToItem() does not work after draw. Here I attach this project. Anybody can feel free to test it in different Qt versions. In my Qt 4.7 installation I always get following result in console: Must be QPointF(30, 10), but got QPointF(10, 5)

    If anybody can tell what I'm doing wrong or how to solve this problem - please tell me. This was greatly slowed my main project and I don't see the solution. PLEASE HELP!
    Attached Files Attached Files

Similar Threads

  1. MapToItem, MapToScene
    By mvbhavsar in forum Newbie
    Replies: 7
    Last Post: 22nd November 2017, 17:45
  2. Replies: 1
    Last Post: 13th November 2014, 08:15
  3. Using QGraphicsItem::mapToScene
    By Casper14 in forum Qt Programming
    Replies: 2
    Last Post: 22nd July 2014, 21:40
  4. Replies: 2
    Last Post: 2nd July 2012, 12:54
  5. remove item for QGirdLayout doesn't work.
    By klnusbaum in forum Qt Programming
    Replies: 4
    Last Post: 23rd May 2008, 23:04

Tags for this Thread

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.