コード例 #1
0
void MultiLayer::makeTransparentLayer(Graph *g)
{
Plot *plot = g->plotWidget();
int lw = plot->lineWidth();
int x = g->x();
int y = g->y();

QRect rect = QRect (plot->x() + lw, plot->y() + lw, plot->width() - 2* lw, plot->height() - 2*lw);
QwtPlotLayout *plotLayout=plot->plotLayout();
plotLayout->activate(plot, rect, 0);

QPixmap pix = QPixmap::grabWidget (canvas, x, y, g->width(), g->height());
plot->setPaletteBackgroundPixmap(pix);
	
QLabel *title=plot->titleLabel ();
QRect tRect=plotLayout->titleRect ();
if (!tRect.isNull())
	{
	pix = QPixmap::grabWidget (canvas, x + tRect.x(), y + tRect.y(), tRect.width(), tRect.height());		
	title->setPaletteBackgroundPixmap(pix);
	}

for (int i=0;i<QwtPlot::axisCnt;i++)
	{
	QwtScale *scale=(QwtScale *) plot->axis (i);
	if (scale)
		{
		QRect sRect=plotLayout->scaleRect (i);
		pix = QPixmap::grabWidget (canvas,x+sRect.x(),y+sRect.y(),sRect.width(), sRect.height());		
		scale->setPaletteBackgroundPixmap(pix);
		}
	}
		
QwtPlotCanvas *plotCanvas = plot->canvas();
QRect cRect=plotLayout->canvasRect ();
pix = QPixmap::grabWidget (canvas,x+cRect.x(),y+cRect.y(),cRect.width(), cRect.height());	
plotCanvas->setPaletteBackgroundPixmap(pix);

plot->replot();
}