How about using QGraphicsScene::setBackgroundBrush()?
How about using QGraphicsScene::setBackgroundBrush()?
setBackgroundBrush overides scene's background. I have a custom background in the scene and do not want to change this. Scene rect is smaller than the view size, and to hide that I need to set the same colour for the view and for the scene.
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
In that case try changing the QPalette::Base component of the view's palette.
This do not work:
Qt Code:
QPalette palette; m_view->setPalette(palette); m_view->repaint(true);To copy to clipboard, switch view to plain text mode
Still using fitInview -> changes the background. Maybe you have and idea what is invoked in the fitInView? (I know the view is transformed /scaled)
Kacper
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,
I might have found the problem. While changing the background, the view(if the cachBackground is enabled) repainted the background from the cache. When I turned off the cachBackground the repainting works. yet, I can't turn off the background cache, because repainting works 10x slower.
I can reset the cache, but it works slower. Howto update the view background without clearing the cache?(when the cache is enabled) ?
Kacper
Last edited by maverick_pol; 27th February 2008 at 13:12.
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
Maybe you should manualy call update()?
I tried that already. Nothing happens.
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
Don't you think that every update causes the background cache to be regenerated? If so, you can turn off the cache, redraw the background and then turn the cache back on.
Well if you are changing something in the background then naturally you need to reset the cache. As you seem to have discovered, QGraphicsView::resetCachedContent () is the key to that.
Of course the following repaint will be slower because it needs to regenerate the cache. You can't get away from that.
Bookmarks