I'm not really a QGraphicsView expert and I've only got 4.2.1 at work so I had to hack out some of the hints, but you might find that the odd "update();" at the end of your zoomin, zoomout and mousemove routines might help a bit.
Pete
I'm not really a QGraphicsView expert and I've only got 4.2.1 at work so I had to hack out some of the hints, but you might find that the odd "update();" at the end of your zoomin, zoomout and mousemove routines might help a bit.
Pete
all ideas are usefull.
I will try using "update()" and give you the result, but this probably will not solve all the problems.
Maverick
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
maverick_pol (24th August 2007)
Sorry. I should rather try to "refresh" the thread.
using "update()", does not give any improvement.
Still looking for a solution. Ideas appreciated.
Maverick
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Alright, I gave it a try but I'm sorry to say I soon gave up. A couple of clear errors:
- a QGraphicsView object allocated on the stack is being deleted => crash
- a QGraphicsView* is incorrectly casted as GView*, an actual GView is never created (once you add a member to GView and try to call it => crash)
Other comments:
I'm not saying any of these particular issues would cause the misfunctionality, but things like public variables and first setting QGraphicsScene::NoIndex in GScene constructor but then switching it immediately to QGraphicsScene::BspTreeIndex in FundGC just make it hard to follow what is being modified and where, and who controls what. Sorry, but the attached code is a bit too "bloated" for an outsider to quickly see what's going on.
J-P Nurmi
Ok, I will correct the mistaked right away.
But do you have ideas why the zooming is wrong ?
I understand that the code may not be as clear and high quality as at your level of coding, but I would like you, if it is not a problem, to look at 2 methods.
fundgc.cpp ->FundGC::vZoomSceneRectangle(QRectF _rectangle);
scene.cpp ->GScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent );
mousePressEvent passes the rectangle for zooming(
and the vZoom... zooms the rectangle. There is an error in the this methods or scene settings, which I can't find on my own.Qt Code:
emit vSignalZoomRectangle(m_zoomPolygonItem->boundingRect());To copy to clipboard, switch view to plain text mode
A -> base class
B: public A
dynamic_cast<B*>(A*) <- why this casting will not work? ( or static)
I really appreciate your help and ideas.
Maverick
Last edited by maverick_pol; 24th August 2007 at 13:24.
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Hi,
I have na idea where the problem lays(I suppose that wysote suggested it at the beginning in the first place, but didn't understand the idea). I belive the problem is connected with scene/view sizes.
Here is the information about the view/scene sizes after construction and their sizes while doing the first zooming.
Just after construction:
Qt Code:
qDebug()<<m_view->size().height()<<m_view->size().width(); m_scene->setSceneRect(-50,50,m_view->width(),m_view->height()); qDebug()<<m_scene->sceneRect().height()<<m_scene->sceneRect().width();To copy to clipboard, switch view to plain text mode
Before doing the first zooming :100 30
100 30
Qt Code:
qDebug()<<m_view->size().height()<<m_view->size().width(); qDebug()<<m_scene->sceneRect().height()<<m_scene->sceneRect().width();To copy to clipboard, switch view to plain text mode
I would like to have the same coordinate system in the scene and the view. It looks like because of the scene/view size different the zooming is incorrect. Am I right?660 1224
100 30
Because the first zooming rectangle(from my example zooming) has coordinates:
-285 157
215 157
-285 -143
215 -143
and it's bigger than the scene, so I zoom the whole(the center).
Ok...I belive this is the problem, but yet do not know how to fix it ?
Any help appreciated.
Maverick
Last edited by maverick_pol; 25th August 2007 at 13:04.
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
You are creating the scene before the view is first shown. It such situation you can't rely on the view size, thus such small size of the scene. This probably causes the problem - when you zoom enough, the scene will become bigger than the view (after the transformation), causing the zoom to really happen (with wrong parameters, of course).
And that's what I was saying from the very beginning...
BTW. Try doing:
You don't have to break QSize (and other value based Qt classes) to lowlevel bits like width and height when passing them to qDebug - they'll be printed correctly without that. It simplifies debugging structures very much, you should try it.Qt Code:
To copy to clipboard, switch view to plain text mode
maverick_pol (28th August 2007)
Hi,
Yes I do agree that your hints were correct:
I see that in my code I have to methods, and firstly I set the scene rect(using mview attributes) and then when I show the view(at my window is maximized view size changes, but not the scene coordinate system).And that's what I was saying from the very beginning...
Thank you for the idea:
I will test it righ away and try to fix the zooming problem.You don't have to break QSize (and other value based Qt classes) to lowlevel bits like width and height when passing them to qDebug - they'll be printed correctly without that. It simplifies debugging structures very much, you should try it.
Maverick
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Ok the problem is clear, but can't really get what I want.
During construction view size is (30,100). Then after maximixing (660,1224).
I can't set m-scene rectangle as (30,100) because after maximizing the coordinates are wrong. I tried setting the scene rectangle to (660,1224), but than the scene is much bigger than the viewport. My scene should always be the same size as the viewport, have the same coordinates system.
Howto achieve this? I am trying to fix it, but still when zooming is Ok the scene is to big and I have to center is in the view.
Maverick
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Ok, problem solved.
I thank everyone, who helped me, especially wysota.
Maverick
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
So what was the solution?
Bookmarks