PDA

View Full Version : QGraphicsView scroll bars disappears



jano_alex_es
24th November 2009, 15:46
Hi,

in my scene I use to have a lot of removable items, so most of times the scene is bigger than expected, way more sometimes.

I want to solve this by updating, by code, its size qhen the user presses a button.

I'm doing:

QRectF itemRec = m_pSkScene->itemsBoundingRect();
m_pSkScene->setSceneRect(itemRec);
//m_pSkScene.views().at(0)->setSceneRect(itemRec);
ui.graphicsView->setSceneRect(itemRec);

it resizes right, but when an item goes out the scroll bar doesn't appears as before. Setting "scrollBarAlwaysOn" doesn't solve it.

any idea? thanks!

jano_alex_es
25th November 2009, 13:04
Some images:

first of all, the scene has few graphicsItems, and it's too large

http://img248.imageshack.us/img248/8471/28813472.jpg


So the code is executed, in order to make it smaller.

http://img4.imageshack.us/img4/2636/82546740.jpg


But, the scroll bar are disabled... and they don't enable even if I move an item outside the view.

http://img163.imageshack.us/img163/4897/78439938.jpg


Seems like I forgot something basic... but I don't know what :S

Lykurg
25th November 2009, 13:12
Try not to set the scene rect by using the view. Only use QGraphicsScene::setSceneRect(). And did you draw the arrows outside the bounding rect of the items?

jano_alex_es
25th November 2009, 14:12
Try not to set the scene rect by using the view

I'm trying with both, and with both at the same time as well and it's the same.



And did you draw the arrows outside the bounding rect of the items?

Yes, actually I can even move them. I can also create, by code, new items outside the viewport but only access to them if I resize the view manually.

Is it, for any chance, the expected behavior?

Lykurg
25th November 2009, 14:17
Yes, actually I can even move them. I can also create, by code, new items outside the viewport but only access to them if I resize the view manually.

You didn't get me right. Did you draw the arrows yourself in the paint method of a subclassed item? If so, make sure, you respect the bounding rect of that item, that you don't draw outside.

Anyway, can you make a minimal compilable example reproducing your problem.