多くのアイテムを行に表示するカスタム ウィジェットがあります。
void update(){ //this is a SLOT which is connected to a button click
QVBoxLayout *layout = this->layout();
if (layout == NULL){
layout = new QVBoxLayout;
this->setLayout(layout);
} else {
QLayout_clear(layout); //this is a function that I wrote that deletes all of the items from a layout
}
ArrayList *results = generateData(); //this generates the data that I load from
for (int i = 0; i < results->count; i++){
layout->addWidget(new subWidget(results->array[i]));
}
}
問題は、約 900 のアイテムがあり、プロファイルによると、子オブジェクトをレイアウトに追加するだけで 50% の時間がかかる (構築に残りの 50% かかる) ことです。全体として、すべてのアイテムをロードするのに約 3 秒かかります。
ボタンをクリックしてさらにデータをロードすると、UI 全体が 3 秒間フリーズし、すべてが完了するとすべての項目が一緒に表示されます。作成中のアイテムを徐々にロードする方法はありますか?