Hi all,
I begin to write a simple application that load data from database and I want to use QProgressBar but I don't know exactly how it works, pls show it for me in details.
Thanks in advance.
Printable View
Hi all,
I begin to write a simple application that load data from database and I want to use QProgressBar but I don't know exactly how it works, pls show it for me in details.
Thanks in advance.
It is very easy to use one.
Create it,put it in a layout, set it's max and min value, and then call setValue to update it.
You also can look at QProgressDialog beacuse it uses a QProgressBar.
Regards
In my program, I want to connect to database that verify user input, please tell me how to make progressbar describe this progress.
Beforehands thanks.
Anh.:)
Everything you need to know is simple:
1) Create QProgressBar
2) setMin setMAx
3) setValue according to some sort of SIGNAL, like if database connected maybe connect a function to add like 20 more % to progressbar
Take a look at examples in your Qt folder, like HTTP or FTP example.
QProgressDialog *dlg = new QProgressDialog(0,Qt::Popup);
here is a sample wo user can not stop dlg->setCancelButton(0); && query... result is a dump file
Code:
void ExportSql() { if (OSWinServer()) { table = table.toUpper(); /* bastard win ! */ } bool ok; if (cfileName.size() > 0 && cfileName !=ba ) { if (!cfileName.endsWith(".sql")) { cfileName = cfileName+".sql"; } } else { return; } dlg->setLabelText (tr("Export table \"%1\" from %2").arg( table ).arg(db.hostName())); dlg->setCancelButton(0); //////dlg->setMaximum(100); //////dlg->setValue(0); qDebug() << "### ExportSql " << table; QStringList cvslines; QStringList Fname; QStringList Fvalue; cvslines.clear(); bool suppoaffect; int sumcol = rec.count(); int sumrow = query.numRowsAffected(); int recnum = 0; /* QProgressDialog *dlg; */ int pasero = 0; while (query.next()) { recnum++; /* count fake lines */ dlg->setMaximum(100); dlg->setValue((recnum * 100) / sumrow ); Fvalue.clear(); Fname.clear(); for(int i=0;i<sumcol;i++){ bool oknr = false; value = value.replace("\n","\\n"); value = value.replace("\t","\\t"); value = value.replace("\r","\\r"); if ( typeoffield == "int" ) { int vnummer = value.toInt(&oknr); } if (oknr) { Fvalue.append(value); } else if (value.isEmpty()) { Fvalue.append(DefaultFieldFrom(table,fname)); } else { } } } dlg->close(); stream.append(cvslines.join("")); /////////qDebug() << "### stream " << stream; { sw << stream; f.close(); } else { } } { int sumcol = rec.count(); while (query.next()) { if ( feldname == field ) { if (svl.size() < 1) { return xdefault; } else { return svl; } } } return xdefault; }
Hi patrik08,
With your code, I understand it exactly now,
thank patrik08 a lot :)