Results 1 to 2 of 2

Thread: Centering a window

  1. #1
    Join Date
    Mar 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Centering a window

    All,

    I think PyQt had a .Centre() method that would center a window, but I can't find its counterpart in C++. Anyone?

    David.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Centering a window

    You have to calculate by your own:
    Qt Code:
    1. QRect rect = QApplication::desktop()->availableGeometry(widget);
    2. widget->move(rect.center() - widget->rect().center());
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Vertical centering of a QTextEdit
    By miwarre in forum Newbie
    Replies: 4
    Last Post: 5th October 2015, 06:01
  2. Centering a Widget in Graphics View
    By tbcpp in forum Qt Programming
    Replies: 4
    Last Post: 23rd June 2009, 06:18
  3. Centering An Icon In A QTableWidgetItem?
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 15th November 2007, 00:11
  4. QTableWidgetItem: Headers and centering items
    By thebra in forum Qt Programming
    Replies: 3
    Last Post: 6th August 2007, 01:00
  5. centering combobox text
    By illuzioner in forum Qt Programming
    Replies: 4
    Last Post: 30th May 2007, 15:06

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.