I'm afraid I can't repeat your problem using your code on any of my systems (Mac, Windows7 or Linux), the dialog always comes up centered irrespective of the MainWindow state. What's your setup? You could try setting the dialog's parent to the MainWindow (i.e. QMessageBox(self)), its generally good practice and a good idea to give widgets a parent.
As a more general answer to your question, the following example demonstrates centering a dialog on the screen:
@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class Dialog(QDialog):
def init(self, parent=None):
QDialog.init(self, parent)
if name=="main":
from sys import argv, exit
a=QApplication(argv)
d=Dialog()
d.show()
d.raise_()
exit(a.exec_())
@
This will work for any QWidget derivative.