求助QGraphicsScene QGraphicsView 图形框架问题

明卿 2017-12-10 09:34:11
QGraphicsScene QGraphicsView 图形框架中 继承的QGraphicsScene类 里面的drawBackground接口贴了背景图,可以正常显示QGraphicsScene的背景图,然后在继承的QGraphicsView 类里面也实现了drawBackground后就看不到QGraphicsScene贴的背景图片了,把QGraphicsView 的drawBackground注释掉才能看到图片,什么原因跪求大神指点


class MyQGraphicsScene : public QGraphicsScene
{
public:
MyQGraphicsScene( QObject* pParent = 0 );
// QGraphicsScene interface
protected:
void drawBackground(QPainter *painter, const QRectF &rect);
void drawForeground(QPainter *painter, const QRectF &rect);
};

class MyQGraphicsView : public QGraphicsView,
protected QOpenGLFunctions
{
public:
MyQGraphicsView( QWidget* pParent = 0 );

// QGraphicsView interface
protected:
void drawBackground(QPainter *painter, const QRectF &rect);

void InitGL();
void ResizeGL(int width, int height);
void PaintGL();
};


...全文
336 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
加盾男爵 2017-12-11
  • 打赏
  • 举报
回复

传图失误。。。。应该是这张
加盾男爵 2017-12-11
  • 打赏
  • 举报
回复
QGraphicsScene和QGraphicsView两者关系差不多是这样的

网格是QGraphicsScene绿色的显示框就是QGRaphicsView
简单的来说就是view在scebe的上面,所以view设置背景图片就把scene挡住了。。。

16,203

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧