Skip to content

Commit

Permalink
Set the background for layouts on the view, rather then in the scene
Browse files Browse the repository at this point in the history
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 28281ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/layout/qgslayout.cpp
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions src/gui/layout/qgslayoutview.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 28281ee

Please sign in to comment.