我从服务器获得连续的答案,延迟时间为 1 秒。我将这个答案附加到 QTextEdit 字段。但是当方法调用完成时,更改首先显示。如何立即显示更改?我已经尝试过 update() 但它不起作用..
void ClientWidget::setAnswer(ValueStream *resultStream){
std::vector<std::string> answer;
for(int i = 0; i < 15; i++){
value tmpResultValue;
if(resultStream->get(tmpResultValue)){
this->client.parseResult(tmpResultValue, answer);
std::vector<QString> qAnswer = vectorStringToVectorQstring(answer);
for (unsigned int n = 0; n < qAnswer.size(); n++){
this->answerTextEdit->append(qAnswer[n]);
}
this->answerTextEdit->update();
}
answer.clear();
}
resultStream->close();
delete resultStream;
}
在这之后->answerTextEdit->append(qAnswer[n]); 应显示更改,但不会立即显示