PDA

View Full Version : how to put a dialog in the center of the screen



biswajithit
4th September 2008, 09:38
hi,

i am using a QDialog to popup some meaasges (some other stubs are also there).

but the dialog is not popuping in the center. it is always popuping at left side.

is there any properties to set to get it in center?


regards
biswajit

biswajithit
4th September 2008, 09:48
i am using Qt 4.3.4 in solaris

BrainB0ne
4th September 2008, 09:50
Thats a problem i also have to deal with sometimes!

I usually use the following method for centering a dialog
I put this code at the constructor of a dialog.



QRect scr = QApplication::desktop()->screenGeometry();
move( scr.center() - rect().center() );


But this will sometimes not be so nice on systems where dual monitors are used in extended desktop mode. Then the dialog centers at the center of the 2 monitors.


Ah i forgot to say, im using Qt3, but maybe it will work for version 4 also...

aamer4yu
4th September 2008, 10:13
May be u can use

QRect scr = QApplication::desktop()->screescreenGeometry(0);
0, to indicate the first screen :)

biswajithit
4th September 2008, 13:24
thanks......

it really helps....

have a good day...