QT5中运行QT4场景程序 QGraphicsItem *QGraphicsScene::itemAt 函数报错的解决

#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsRectItem>
#include <QDebug>
#include <QGraphicsView>
#include <QPainter> //QT5 添加
#include "myitem.h"

int main(int argc,char* argv[ ])
{
    QApplication app(argc,argv);
 
 
    //新建场景
    QGraphicsScene scene;
    //创建矩形图形项
QTransform transform;    //QT5添加
    transform.rotate(+0.0);//QT5添加
    QGraphicsRectItem *item = new QGraphicsRectItem(0, 0, 100, 100);
    //将图形项添加到场景中
    scene.addItem(item);
    //输出(50, 50)点处的图形项
qDebug() << scene.itemAt(50, 50,transform);  //  QT5添加 transform
 
 
 
 
    //为场景创建视图
    QGraphicsView view(&scene);
    //设置场景的前景色
    view.setForegroundBrush(QColor(255, 255, 255, 100));
    //设置场景的背景图片
    view.setBackgroundBrush(QPixmap("../myScene/background.png"));
    view.resize(400, 300);
    view.show();
 
 
    return app.exec();
}
qt4中函数QGraphicsItem *QGraphicsScene::itemAt(qreal x, qreal y)
qt5中函数发生了变化

QGraphicsItem *QGraphicsScene::itemAt(qreal x, qreal y, const QTransform &deviceTransform) const

This is an overloaded function.

Returns the topmost visible item at the position specified by (x, y), or 0 if there are no items at this position.

deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.

This convenience function is equivalent to calling itemAt(QPointF(x, y), deviceTransform).

Note: See items() for a definition of which items are considered visible by this function.

This function was introduced in Qt 4.6.

转载于:https://www.cnblogs.com/yekongdexingxing/p/6274737.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值