记一次纯虚函数调用
来源:互联网 发布:网络监控能看到啥 编辑:程序博客网 时间:2024/06/10 01:16
背景,一个基于QDeclarativeItem的画布,一个基于QDeclarativeItem的显示控件(父对象为画布)
如果调用了画布的setScale函数之后,不管输入什么值,再次添加显示控件的时候会报一个纯虚函数错误。
看断点定位是
QPointF QDeclarativeItemPrivate::computeTransformOrigin( )const报的错,而该函数内容很简单3002 {
3003 Q_Q(constQDeclarativeItem);
3004
3005 QRectF br = q->boundingRect();
3006
3007 switch(origin) {
3008 default:
3009 case QDeclarativeItem::TopLeft:
3010 return QPointF(0, 0);
3011 case QDeclarativeItem::Top:
3012 return QPointF(br.width() / 2., 0);
3013 case QDeclarativeItem::TopRight:
3014 return QPointF(br.width(), 0);
3015 case QDeclarativeItem::Left:
3016 return QPointF(0, br.height() / 2.);
3017 case QDeclarativeItem::Center:
3018 return QPointF(br.width() / 2., br.height() / 2.);
3019 case QDeclarativeItem::Right:
3020 return QPointF(br.width(), br.height() / 2.);
3021 case QDeclarativeItem::BottomLeft:
3022 return QPointF(0, br.height());
3023 case QDeclarativeItem::Bottom:
3024 return QPointF(br.width() / 2., br.height());
3025 case QDeclarativeItem::BottomRight:
3026 return QPointF(br.width(), br.height());
3027 }
3028 }
这当中只有q->boundingRect();是纯虚函数,而实际上这个函数每个子类都有实现,理论上不会报错。
最后的解决方案是……new 控件的时候不指定父对象(构造函数参数为空),然后使用setParentItem来指定父对象,问题解决。
怀疑是Qt版本问题,4.8.6正常,4.8.5以下会出现……
阅读全文
0 0
- 记一次纯虚函数调用
- 纯虚函数的调用
- 纯虚函数的调用
- R6025调用纯虚函数错误
- 函数只调用一次
- 纯虚函数调用 pure virtual function call 错误
- 【转】纯虚函数调用 pure virtual function call 错误
- 记一次实验——复杂函数指针的调用
- 父类的构造函数中不能调用纯虚函数,同样在析构函数中不能调用纯虚函数
- 在父类的构造函数和析构函数中都不能调用纯虚函数
- 在父类的构造函数和析构函数中都不能调用纯虚函数
- 纯虚函数
- 纯虚函数
- (纯)虚函数意义
- 纯虚函数
- c++纯虚函数
- 纯虚函数(转)
- 纯虚函数
- 苹果说,这次真的是By Design
- 从薛之谦事件看吃瓜群众
- 冒泡排序实现
- 什么情况下document.write会覆盖页面及覆盖原理解释
- 返回结果的HTTP状态码
- 记一次纯虚函数调用
- 二、利用ViewPage制作启动而
- Vivox7手机格式化照片找回方法
- HDU:Sum It Up(深搜)
- Ubuntu 16.04 下的安装与配置ambari
- 硅谷程序员人才大量流失,美国的优秀程序员都去哪儿了?
- 入职合同2亿美元,Uber新CEO伊朗俊杰究竟何许人?
- 程序员哥哥,你有一枚女朋友请查收。
- 雷 · 阿伦:给13岁自己的一封信