Results 1 to 4 of 4

Thread: How to show thw widget in center?

  1. #1
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default How to show thw widget in center?

    Hi All
    i've a dialog of size 401,431. I want to display it in the centre of my screen. But its showing at different position in different systems. (may be because of the different resolution ). How to achive it.
    in constructor, I did like

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

    But its not working.
    Plz help.

  2. #2
    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 show thw widget in center?

    What does center() return ??
    You want your widget's top left corner to be on the center of screen ? Or you want the widgets center to be in the center of screen ?
    Rest is all calculations

  3. #3
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to show thw widget in center?

    Quote Originally Posted by aamer4yu View Post
    What does center() return ??
    You want your widget's top left corner to be on the center of screen ? Or you want the widgets center to be in the center of screen ?
    Rest is all calculations
    Hi
    I want to show it in the center of screen. (of my Desktop).

  4. #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 show thw widget in center?

    So do you think
    this->move(QApplication::desktop()->screenGeometry().center());
    was proper calculation ?

    Shouldnt it be something like screen().center() - widget.center() ??

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, 21:43
  2. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  3. Show in center
    By lisa in forum Qt Programming
    Replies: 3
    Last Post: 22nd November 2009, 11:42
  4. Center a widget in a cell on a QTableWidget
    By roleroz in forum Qt Programming
    Replies: 16
    Last Post: 5th March 2009, 14:47
  5. Show dialog in screen center
    By mourad in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2008, 13:41

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.