繁体   English   中英

在Qt中从第二个graphicsview的场景中忽略drawForeground()

[英]Ignore drawForeground() from the scene on the 2nd graphicsview in qt

我有自己的QGraphicsScene和两个QGraphicView。 在QGraphicsScene中,我使用

drawForeground(QPainter *painter, const QRectF &rect)

绘制网格的功能。 现在我只希望网格在第一个视图中可见,而在第二个视图中不可见……这可能吗?

QGraphicsView是通向世界的窗口(QGraphicsScene)。 您要问的是说在窗户外面看时正在下雨,但是当我透过窗户之一看时只能下雨吗?

但是,您可以更改窗帘(!),因此可以重写QGraphicsView而不是QGraphicsScene的功能。 我建议使用此:-

QGraphicsView::drawForeground(QPainter *, const QRectF &);

将此仅应用于您要更改的视图。 对于两个视图,您将需要一个标志来设置要将其应用于哪个视图。 例如: -

 void MyGraphicsView::drawForeground(QPainter* painter, const QRectF& rect)
 {
     QGrahicsView::drawForeground(painter, rect);
     if(m_bDrawGrid)
         DrawGrid(); 
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM