Skip to content
Permalink
Browse files

Set the background for layouts on the view, rather then in the scene

Setting the background on the scene means in applies in renders
of the scene (e.g. to images). We don't want this - we always
want scenes rendered on transparent backgrounds. So instead
use stylesheets to only show the grey background outside of pages
in the view.
  • Loading branch information
nyalldawson committed Jul 25, 2017
1 parent fabfd77 commit 28281ee896881332566739eff5a362d85c95aa92
Showing with 8 additions and 1 deletion.
  1. +2 −1 src/core/layout/qgslayout.cpp
  2. +6 −0 src/gui/layout/qgslayoutview.cpp
@@ -22,7 +22,8 @@ QgsLayout::QgsLayout( QgsProject *project )
, mProject( project )
, mPageCollection( new QgsLayoutPageCollection( this ) )
{
setBackgroundBrush( QColor( 215, 215, 215 ) );
// just to make sure - this should be the default, but maybe it'll change in some future Qt version...
setBackgroundBrush( Qt::NoBrush );
}

void QgsLayout::initializeDefaults()
@@ -40,6 +40,12 @@ QgsLayoutView::QgsLayoutView( QWidget *parent )
setMouseTracking( true );
viewport()->setMouseTracking( true );

// set the "scene" background on the view using stylesheets
// we don't want to use QGraphicsScene::setBackgroundBrush because we want to keep
// a transparent background for exports, and it's only a cosmetic thing for the view only
// ALSO - only set it on the viewport - we don't want scrollbars/etc affected by this
viewport()->setStyleSheet( QStringLiteral( "background-color:#d7d7d7;" ) );

mSpacePanTool = new QgsLayoutViewToolTemporaryKeyPan( this );
mMidMouseButtonPanTool = new QgsLayoutViewToolTemporaryMousePan( this );
mSpaceZoomTool = new QgsLayoutViewToolTemporaryKeyZoom( this );

0 comments on commit 28281ee

Please sign in to comment.
You can’t perform that action at this time.