In QT,ProgramAfter running, the window is displayed in the center of the screen by default, but it is not displayed in the center of the XP system. You need to adjust it manually.
Like other online solutions, most people useCode
Move (desktop-> width ()-This-> width ()/2, (desktop-> height ()-This-> height ()/2 );
This code has two problems.
1. The width and height of the desktop contain the width and height of the taskbar, which may cause the window location to be less accurate. For example, the top and bottom values of the window may be much different.
2. the taskbar is left, top, and right.
The improved code is as follows:
W. move (qapp-> desktop ()-> availablegeometry (). width ()-w. width ()/2 + qapp-> desktop ()-> availablegeometry (). X (), (qapp-> desktop ()-> availablegeometry (). height ()-w. height ()/2 + qapp-> desktop ()-> availablegeometry (). Y ());
Availablegeometry is the rectangular area returned that does not contain the taskbar. This ensures that the center position is more accurate.
Add the XY coordinates of availablegeometry to ensure that the program can also appear in the correct position on the desktop that has adjusted the taskbar position, instead of overlapping the taskbar.