1.获取父窗口相对于屏幕的坐标,即绝对坐标 2.计算子窗口的坐标 3.移动窗口
QPoint globalPos
= parentWidget
->mapToGlobal(QPoint(0,0));
int x
= globalPos
.x() + (parentWidget
->width() - this->width()) / 2;
int y
= globalPos
.y() + (parentWidget
->height() - this->height()) / 2;
this->move(x
, y
);
转载请注明原文地址:https://tech.qufami.com/read-16303.html