Two Message Boxes in a Row Positions Second One in an Odd Place
-
In my app all my messages are positioned in the middle of the main window unless I exec 2 in a row. The second one gets placed in the upper left hand corner of left monitor. The app is on the right monitor. This looks very odd and confuses the user. Any ideas?
-
@DougyDrumz hi, friend.
I didn't clear well about what you problem. Can you show some code snippet or some screenshot?
-
Unfortunately my code is on a different, classified network. I.e., you can't get there from here. I'll see if I can be more clear:
... myQuestionbox = new QMessageBox(this); ... int reply = myQuestionBox->exec(); if (reply == QMessage::Yes) { resetConfirm(); } ... void MyClass::resetConfirm() { ... int reply = myQuestionBox->exec(); if (reply == QMessage::Yes) { doSomething(); } ... }
When I call the first myQuestionBox->exec(), the QuestionBox is displayed in the center of the the main window, which is on the right monitor. When I call the second myQuestionBox->exec(), the QuestionBox is displayed in the upper left-hand corner of of the left monitor. In fact, any myQuestionBox I exec gets displayed in the center of the of the main window on the right monitor, unless the first myQuestionBox calls code which execs a second myQuestionBox. Then the second myQuestionBox gets displayed in the upper left-hand corner of the left monitor.
-
do you have two monitors ?
Why did not you use the
QMessageBox static function
or use thelocal QMessageBox variable
?StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons = StandardButtons( Yes | No ), StandardButton defaultButton = NoButton)
if you must be use
new QMessageBox
, and you have two monitors. you can get the screens fromQGuiApplication
.[static] QList<QScreen *> QGuiApplication::screens()
and then, you can to see
QScreen public classes in Qt help
. you can know screen size etc.at second
exec
, usingmove
function. maybe it can successed.try it.
-
@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.