嗨,我有一个 GridLayout,上面有 64 个 GraphicsViews(我知道它很多,但这是我目前能想到的唯一方法)。现在,我目前只是在计时器刻度上的每个图形视图上绘制一条随机线。这仅适用于图形中的 8 个,创建图形视图
void Simulation::createGraphicsViews(){ for(int i = 0; i < 64; i++){ for(int j = 0; j < 8; j++){
graphicsScene[i] = new QGraphicsScene();
graphicsView[i] = new QGraphicsView(graphicsScene[i]);
simui->gridLayout->addWidget(graphicsView[i], i/8, j);
}
}
}
每个图形视图中的随机线
for(int x = 0; x < 64; x++){
x1 = qrand()%(50+1) - 1;
y1 = qrand()%(50+1)-1;
x2 = qrand()%(50+1)-1;
y2 = qrand()%(50+1)-1;
graphicsScene[x]->addLine(x1,y1,x2,y2);
qDebug() << "adding line to" << x << "at" << x1 <<","<<y1<<","<<x2<<","<<y2;
}
显示更新的图形视图
for(int x = 0; x < 64; x++){
graphicsView[x]->show();
qDebug()<<"showing" << x;
}
在过去的 2 个小时里,我已经查看了它,尝试了多种方法,但都没有解决这个问题,我假设这可能是愚蠢的,但我就是想不通
非常感谢任何帮助谢谢
此外,如果我尝试更新任何图形视图,但它们仍然不会更新。
https://gist.github.com/gazza126/f43d5b0377649782a35d——完整代码(可以做任何事情)