I have a class that contains ProgressBar. On another interface when I pressed the button, it will perform the reading of data and pour on the board. I will call it class ProgressBarbar to display the time it made it finished I will close the progress bar behind you. I do not know why sometimes the progress bar was run forever made without closing it. It appears with a low rate. Expect people to explain me, maybe because I use the progress bar wrong. :)
code this:
Code:
void TopMenu::onbtLoadData_clicked() { if(mDialog==NULL) { mDialog= new ThanhDialogTable(NULL); mDialog->exec(); delete mDialog; mDialog = NULL; } }
class ThanhDialogTable:
Code:
ui(new Ui::ThanhDialogTable) { ui->setupUi(this); QFuture<void> *m_future = new QFuture<void>; m_SimpleProgress = new SimpleProgressBar(); m_SimpleProgress->SetContent("Load Data......"); *m_future = QtConcurrent::run(ThanhDialogTable::loadData, m_SimpleProgress); m_SimpleProgress->exec(); }
and loadData of ThanhDialogTable
Code:
bool ThanhDialogTable::loadData(FiSK_SimpleProgressBar *pProgress) { /* Here I call to read data to get one list data from the database and then I put that data into the table and display */ ui->m_table->setColumnCount(labels.count()); ui->m_table->setHorizontalHeaderLabels(labels); QList<int> columnWidths; columnWidths << 49 << 129 << 99; ui->m_table->setColumnWidth(ColumnType::No, columnWidths[ColumnType::No]); ui->m_table->setColumnWidth(ColumnType::Name1, columnWidths[ColumnType::Name1]); ui->m_table->setColumnWidth(ColumnType::Name2, columnWidths[ColumnType::Name2]); QTableWidgetItem *item_name1; QTableWidgetItem *item_name2 ; QTableWidgetItem *item_No; int count = m_ListData.size(); ui->m_table->setRowCount(count); for (int i = 0; i < count; i++) { item_name1->setText(m_ListData.at(i).mName1); item_name2->setText(m_ListData.at(i).mName2); ui->m_table->setItem(i,0,item_No); ui->m_table->setItem(i,1,item_name1); ui->m_table->setItem(i,2,item_name2); } //Close progress bar pProgress->hide(); pProgress->close(); }
Please help me and sympathetic English in the level. :)