简体   繁体   中英

Moving QMessageBox?

Basically I'm learning the basics of Qt C++ and I'm trying to open up two different QMessageBox 's at the same time but they overlap each other. I was wondering if it was possible to have them side by side. Any input on how to do so would be greatly appreciated.

Extra information: I'm opening them by using the QMessageBox::name(this,"Title", "Text") way.

That does not really make sense. QMessageBox is not for arbitrary windows, but specifically for modal dialogs. The user cannot interact with two modal dialogs. Anyway, I don't see anything in the documentation that would allow you to align message boxes or set coordinates etc.

Edit: As Marian noted, there is the move method of QWidget . This might work, but I would not recommend it. Modal dialogs are usually not presented side by side. This might confuse the user.

If you really need two windows side by side, non-modal (custom) windows or dock widgets might be a better solution.

You can use QMessageBox::move(int x, int y) to place the message box where you want on the screen. You can also use QMessageBox::setGeometry(int x, int y, int width, int height) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM