for (int i = 0; i < agvs.size(); i++) { if (agvs[i].getLoad()){ painter.drawPixmap(agvs[i].getCurrentX()*25+200-(nodeSpacing-nodeSize)/2,(agvs[i].getCurrentY()+1)*25+50-(nodeSpacing-nodeSize)/2,25,25,QPixmap(":/new/prefix1/agvload.png").scaled(25,25)); } else { painter.drawPixmap(agvs[i].getCurrentX()*25+200-(nodeSpacing-nodeSize)/2,(agvs[i].getCurrentY()+1)*25+50-(nodeSpacing-nodeSize)/2,25,25,QPixmap(":/new/prefix1/agv1.png").scaled(25,25)); }},讓圖片在畫面中處於最上層
时间: 2023-11-22 10:54:55 浏览: 52
AGVS.rar_AGVS调度_gulf5j4_scheduling AGV_wpf agv调度系统_调度控制
5星 · 资源好评率100%
你可以使用 `QPainter` 的 `setCompositionMode` 函数来设置图像的混合模式,从而让绘制的图像处于最上层。以下是一个示例代码:
```
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
for (int i = 0; i < agvs.size(); i++) {
if (agvs[i].getLoad()){
painter.drawPixmap(agvs[i].getCurrentX()*25+200-(nodeSpacing-nodeSize)/2,(agvs[i].getCurrentY()+1)*25+50-(nodeSpacing-nodeSize)/2,25,25,QPixmap(":/new/prefix1/agvload.png").scaled(25,25));
}
else {
painter.drawPixmap(agvs[i].getCurrentX()*25+200-(nodeSpacing-nodeSize)/2,(agvs[i].getCurrentY()+1)*25+50-(nodeSpacing-nodeSize)/2,25,25,QPixmap(":/new/prefix1/agv1.png").scaled(25,25));
}
}
```
在上面的代码中,我们将混合模式设置为 `CompositionMode_SourceOver`,这是默认的混合模式。这样绘制的图像就会处于最上层。
阅读全文