|
发表于 2019-4-4 10:12:00
|
显示全部楼层
可能与编译器有关。有的编译器忽略。
E:\qt\myGame\myview.cpp:72: error: no matching function for call to 'QGraphicsScene::items(int, int&, int, int, Qt::ItemSelectionMode)'
QList<QGraphicsItem *> list = scene()->items(199, y, 202,22,Qt::ContainsItemShape);
^
错误在y那里。仔细看y应该传引用ref,而实际传的值,编译器认为是
QGraphicsScene::items(int, int, int, int, Qt::ItemSelectionMode)而不是
QGraphicsScene::items(int, int&, int, int, Qt::ItemSelectionMode),故不匹配
这样试一下
for (int y = 429; y > 50; y -= 20) {
int&y1=y;
QList<QGraphicsItem *> list = scene()->items(199, y1, 202,22,Qt::ContainsItemShape,0);
传引用是可以修改原值地。

|
|