GraphicsView 使用时,程序死掉总结

来源:互联网 发布:ug软件下载 编辑:程序博客网 时间:2024/05/01 07:18

1. 使用鼠标滑动 进行缩放时, 程序死掉的问题。 

    bool GraphicsViewEx::event(QEvent *event)    中 重新构造的 是 

        QObject::Event 

而不是 QWidget::Event


2.  删除 已经添加的 Item 时,  程序死掉。 
    删除时应该使用:   {     pView->scene()->removeItem(item);     QGraphicsScene* pScene = pView->scene();}  

    而不是        pScene->removeItem(pItem); 。
 
因为 QGraphicsScene * QGraphicsView::scene () const  为常量

0 0
原创粉丝点击