QDesktopWidget * desktop = qApp->desktop();
QRect rect = desktop->screenGeometry(this);
QRect frameRect = frameGeometry();
if (frameRect.top() == m_RecoverPosition.y() - (curHeight - HIDE_BORDER))
{
MoveWindow(pos(), m_RecoverPosition);
}
else
{
m_IsVisible = false;
}
获取屏幕坐标可以用这种办法,下面是官方说明:
const QRect QDesktopWidget::screenGeometry(int screen = -1) const
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Returns the geometry of the screen with index screen. The default screen is used if screen is -1.
Use QGuiApplication::screens() instead.
可以只用下面的办法获取屏幕坐标: