Basically you just create a QProgressDialog
instance:
QProgressDialog progress("Parsing...", "Abort", 0, numOperations, this);
progress.setWindowModality(Qt::WindowModal);
where numOperations
is the full number of things you need to do before the parsing is done. For this, you probably need to make a first quick pass through the data where you simply count the total number of elements to parse or something similar, and set this value as the maximum value numOperations
in the previous example code. Then you make the actual processing pass and call setValue periodically:
progress.setValue(finishedOperations);
where finishedOperations is the number of things parsed so far.
This is assuming you want the simplest solution where the progress bar appears as a separate modal dialog. If you want to give the user the opportunity to abort the process, you need to implement a slot which you connect to the canceled()
signal.
If you don't want the progress bar in a modal dialog, you just show a QProgressBar
somewhere. It works in a similar way by calling setValue() periodically.