@joeQ As it turns out, I just tried the opposite. I had one newed Message Box for everything. In the place that had the funny location, I made a separate newed Message Box and it ended up in the correct place - the middle of its parent.
pbar is in the VBoxLayout of the dialog, q is a QSqlQuery.
I Just modified the code so that the dialog also contains the yes and no buttons and no QMessageBox is shown. When i now show the QDialog instead of the QMessageBox and then execute the slot, everything looks good and the progressbar is updated at each step of the foreach() loop.
Oh!! Then I need to make a worker class and do something like:
thread = new QThread();
worker = new Worker;
// this is the initialization of a QWizardPage in the QWizard
WizardPageClass1 *page1 = new WizardPageClass1 ;
And then where I have the lengthy operation, emit a signal (DoOperation for example) and in its constructor make a connect like connect(this, DoOperation(), worker, doWork()) if doWork() is where I have the lenghty operation with?