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:
void TopMenu::onbtLoadData_clicked()
{
if(mDialog==NULL)
{
mDialog= new ThanhDialogTable(NULL);
mDialog->exec();
delete mDialog;
mDialog = NULL;
}
}
void TopMenu::onbtLoadData_clicked()
{
if(mDialog==NULL)
{
mDialog= new ThanhDialogTable(NULL);
mDialog->exec();
delete mDialog;
mDialog = NULL;
}
}
To copy to clipboard, switch view to plain text mode
class ThanhDialogTable:
ThanhDialogTable
::ThanhDialogTable(QWidget *parent
): 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();
}
ThanhDialogTable::ThanhDialogTable(QWidget *parent):
QDialog(parent),
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();
}
To copy to clipboard, switch view to plain text mode
and loadData of ThanhDialogTable
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 */
QString select
("No, Name1, Name2");
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]);
int count = m_ListData.size();
ui->m_table->setRowCount(count);
for (int i = 0; i < count; i++)
{
item_No
->setText
(QString::number(i
+1));
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();
}
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 */
QString select("No, Name1, Name2");
QStringList labels = select.split(", ");
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 = new QTableWidgetItem ();
item_name2 = new QTableWidgetItem ( );
item_No = new QTableWidgetItem ( );
item_No ->setText(QString::number(i+1));
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();
}
To copy to clipboard, switch view to plain text mode
Please help me and sympathetic English in the level.
Bookmarks