Results 1 to 5 of 5

Thread: how to put a dialog in the center of the screen

  1. #1
    Join Date
    Jul 2008
    Location
    india
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default how to put a dialog in the center of the screen

    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

  2. #2
    Join Date
    Jul 2008
    Location
    india
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: how to put a dialog in the center of the screen

    i am using Qt 4.3.4 in solaris

  3. #3
    Join Date
    Jan 2006
    Location
    Netherlands
    Posts
    56
    Thanks
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: how to put a dialog in the center of the screen

    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.

    Qt Code:
    1. QRect scr = QApplication::desktop()->screenGeometry();
    2. move( scr.center() - rect().center() );
    To copy to clipboard, switch view to plain text mode 

    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...
    ..:: Still Standing Strong ::..

  4. The following user says thank you to BrainB0ne for this useful post:

    biswajithit (4th September 2008)

  5. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to put a dialog in the center of the screen

    May be u can use
    QRect scr = QApplication::desktop()->screescreenGeometry(0);
    0, to indicate the first screen

  6. #5
    Join Date
    Jul 2008
    Location
    india
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: how to put a dialog in the center of the screen

    thanks......

    it really helps....

    have a good day...

Similar Threads

  1. how to show window in the center of the screen?
    By lovelypp in forum Qt Programming
    Replies: 5
    Last Post: 18th March 2014, 22:43
  2. Show dialog in screen center
    By mourad in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2008, 14:41
  3. how to show Dialog as drawer on the bottom of the parent screen?
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 7th March 2008, 09:00
  4. Dialog sizes and different screen resolutions.
    By hvengel in forum Qt Tools
    Replies: 3
    Last Post: 2nd April 2006, 11:05
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 15:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.