Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:19:30+00:00 2026-06-11T04:19:30+00:00

I saw an example that uses the following to create a point that will

  • 0

I saw an example that uses the following to create a point that will be used to centre a window in Qt:

x = (screenWidth – WIDTH) / 2;

y = (screenHeight – HEIGHT) / 2;

Provided that screenWidth and screenHeight are found using the width() and height() functions respectively of QDesktopWidget.

How does the preceding code centre the window? Yes, I know it centres the window, but couldn’t understand it from a calculation point of view.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:19:32+00:00Added an answer on June 11, 2026 at 4:19 am

    First calculate the total amount of ‘extra’ horizontal space around your window:

    extra_space = screenWidth - your_window_width
    

    now, spread that space at left and right:

    left_space + right_space = extra_space
    

    the space at both sides should be the same:

    right_space = left_space
    ==>  2 * left_space = extra_space
    ==>  2 * left_space = screenWidth - your_window_width
    ==>  left_space = (screenWidth - your_window_width) / 2
    

    that’s your x. The same goes for the y coordinate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw a Java example that had a main method labeled as synchronized, calling
I saw some websites that (for example): if you want to view your message
I saw this C# using statement in a code example: using StringFormat=System.Drawing.StringFormat; What's that
Does jQuery validation plugin have some dependencies? For example, I saw blogposts that said
I looked into the GCC STL (4.6.1) and saw that std::copy() uses an optimized
I saw multiple examples in MSDN that uses to declare the internal fields at
I saw a lot of examples of nowjs that uses a node.js server and
I saw some examples in CSS in w3.org that uses what they called fictional
I have a complex WCF service that uses for example TCP, WindowsLogin, CustomLogin and
i saw this example : Validate that end date is greater than start date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.