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!
Bookmarks