QDesktopWidget *desktop = QApplication::desktop();
Q_ASSERT(desktop != nullptr);
QPoint last_new_window_pos_;
const QRect geometry = desktop->availableGeometry(QCursor::pos());
if (windows_.isEmpty() || windows_.size() == 1) {
const QPoint center = geometry.center();
return QPoint(center.x() - saveWidth / 2, center.y() - saveHeight / 2);
} else {
last_new_window_pos_.setX(last_new_window_pos_.x() + 30);
last_new_window_pos_.setY(last_new_window_pos_.y() + 30);
if ((last_new_window_pos_.x() + saveWidth >= geometry.width()) ||
(last_new_window_pos_.y() + saveHeight >= geometry.height())) {
last_new_window_pos_.setX(0);
last_new_window_pos_.setY(0);
}
return last_new_window_pos_;
}
qt窗口居中显示
最新推荐文章于 2024-05-31 10:28:43 发布