嘿伙计们,我需要在qt下的虚拟桌面中获取特定屏幕的分辨率,并在给定屏幕周围移动窗口。我试过了
QRect screenSize = desktopWidget.availableGeometry(desktopWidget.screen(ui.monitorNumberComboBox->currentIndex()));
现在当我执行
时void MyWindow::setCoordinates(int x, int y)
{
this->move((x-(this->width())/2),(y-(this->height()/2)));
//sets center of window on given coordinates
}
window->setCoordinates(screenSize.width()/2, screenSize.height()/2);
效果很好但仅适用于主屏幕。是否有可能将其用于不同的屏幕,由索引选择?
答案 0 :(得分:-1)
我想你需要打电话:
[..]
QPoint center = screenSize.center(); // Get the center of the screen rect.
window->setCoordinates(center.x(), center.y());