//設置緩存背景模式
setCacheMode(CacheBackground);緩存
//設置背景位圖
void RtPrintView::setBackgroundImage(const QImage &img)
{
m_background = img;
resetCachedContent(); //注意,使用該函數才能刷新背景層
}函數
//繪製背景位圖
void RtPrintView::drawBackground(QPainter *painter, const QRectF &rect)
{
if (!m_background.isNull())
painter->drawImage(sceneRect().toRect(), m_background);
QGraphicsView::drawBackground(painter, rect);
}im
//關鍵在這個函數:
resetCachedContent();img