Important: Please read the Qt Code of Conduct -

Position of QMessageBox : centered on screen

  • Hi,

    I'm using a QMessageBox inside a Widget. The object is build during main widget constructor and I'm using slots to show/hide the QMessageBox.
    I'm experiencing trouble with the QMessageBox position. The first time "show" is called, the box is well centered. Next time, the box is moved to the top left of the screen and move / setGeometry methods don't work to replace it at widget center.

    How can I keep my box on screen center ?

    Thank you. Best.

  • The QMEssagebox is always centered on the parent. The first time the parent is probably set correctly. How it reacts after that is a mystery to me, I never show/hide a QMessageBox, but only create one within a certain scope with modal set (blocking all other inputs to the program) and then when the user clicks a button/closes the messagebox the QMessageBox goes out of scope, releasing it's memory.

Log in to reply