基本的に私がやりたいのは、リスト内の番号ごとに長方形を描くことです。数値が大きいほど、長方形は大きくなります。私の問題は、実際にそれを段階的に実行し、すべての描画の間に数秒待つことです。私はいくつかの解決策を探しましたが、この特定のケースでそれらを機能させることができません。fflushを使用して、バッファー内にあるものをすべて解放できることを確認しましたが、これにどのように使用できるかわかりません。
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setBrush(QBrush(Qt::green, Qt::SolidPattern));
int weight=300/lista.size;
int posx=weight;
for (int i=1; i<=lista.size; i++){
List_node * node = list.get_element_at(i);
int num=node->getValue(); //this returns the value of the node
if (i==3){
painter.setBrush(QBrush(Qt::red, Qt::SolidPattern)); // this line is to draw a rectangle with a different color. Testing purposes.
}
painter.drawRect(posx,400-(num*10),weight,num*10);
sleep(1); //this sleep isn't working correctly.
painter.setBrush(QBrush(Qt::green, Qt::SolidPattern));
posx+=weight;
}
どんな助けでも本当にありがたいです。