PDA

View Full Version : How to popup QDialog at specific location?



lni
22nd January 2009, 17:24
Hi,

I have a QDialog with QMainWindow as parent, I try to popup the dialog at a specific location using move() right before calling exec(), but it always popup at the center of the QMainWindow.

How can I change the QDialog default popup location?

Thanks

fanat9
22nd January 2009, 18:54
It does work for me(4.3.0). The only difference is my dialog is modeless.

Example:
progressDialog->move(x, y);
progressDialog->show();
progressDialog->raise();

lni
22nd January 2009, 19:27
It does work for me(4.3.0). The only difference is my dialog is modeless.

Example:
progressDialog->move(x, y);
progressDialog->show();
progressDialog->raise();

I am using both Qt4.3.2 and Qt4.5 beta in Linux, and I need a modal dialog by doing:

dialog->move( p );
dialog->exec();

Neither Qt version works for me. QDialog is always in the center of the QMainWindow (the parent)

jpn
23rd January 2009, 12:46
From QDialog docs:


Note that QDialog (an any other widget that has type Qt::Dialog) uses the parent widget slightly differently from other classes in Qt. A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget (if it is not top-level itself). It will also share the parent's taskbar entry.