기본적으로 내 목록에서 각 숫자에 대해 사각형을 그립니다. 숫자가 클수록 사각형이 커집니다. 제 문제는 제가 실제로 그것을하고, 단계별로하고, 모든 그림 사이에 몇 초를 기다리고 싶을 때입니다. 나는 몇 가지 해결책을 찾았지만이 특별한 경우를 위해 일할 수는 없습니다. 버퍼에있는 내용을 릴리즈하기 위해 fflush를 사용할 수 있다는 것을 알았지 만, 어떻게 이것을 사용할 수 있을지 모르겠습니다.Qt C++에서 paintevent를 사용하는 루프 내부에서 잠을 자다
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;
}
정말 도움이 될만한 도움이 될 것입니다.
감사합니다. 그것으로 해결되었습니다. –