1.void move(int x, int y);
inline void QWidget::move(int ax, int ay)
{ move(QPoint(ax, ay)); }
void QWidget::move(const QPoint &p)
{
Q_D(QWidget);
setAttribute(Qt::WA_Moved);
if (testAttribute(Qt::WA_WState_Created)) {
if (isWindow())
d->topData()->posIncludesFrame = false;
d->setGeometry_sys(p.x() + geometry().x() - QWidget::x(),
p.y() + geometry().y() - QWidget::y(),
width(), height(), true);
d->setDirtyOpaqueRegion();
} else {
// no frame yet: see also QWidgetPrivate::fixPosIncludesFrame(), QWindowPrivate::PositionPolicy.
if (isWindow())
d->topData()->posIncludesFrame = true;
data->crect.moveTopLeft(p); // no frame yet
setAttribute(Qt::WA_PendingMoveEvent);
}
if (d->extra && d->extra->hasWindowContainer)
QWindowContainer::parentWasMoved(this);
}
void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
{
Q_Q(QWidget);
if (extra) { // any size restrictions?
w = qMin(w,extra->maxw);
h = qMin(h,extra->maxh);
w = qMax(w,extra->minw);
h = qMax(h,extra->minh);
}
if (q->isWindow() && q->windowHandle()) {
QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration();
if (!integration->hasCapability(QPlatformIntegration::NonFullScreenWindows)) {
x = 0;
y = 0;
w = q->windowHandle()->width();
h = q->windowHandle()->height();
}
}
QPoint oldp = q->geometry().topLeft();
QSize olds = q->size();
QRect r(x, y, w, h);
bool isResize = olds != r.size();
if (!isMove)
isMove = oldp != r.topLeft();
// We only care about stuff that changes the geometry, or may
// cause the window manager to change its state
if (r.size() == olds && oldp == r.topLeft())
return;
if (!data.in_set_window_state) {
q->data->window_state &= ~Qt::WindowMaximized;
q->data->window_state &= ~Qt::WindowFullScreen;
if (q->isWindow())
topData()->normalGeometry = QRect(0, 0, -1, -1);
}
QPoint oldPos = q->pos();
data.crect = r;
bool needsShow = false;
if (q->isWindow() || q->windowHandle()) {
if (!(data.window_state & Qt::WindowFullScreen) && (w == 0 || h == 0)) {
q->setAttribute(Qt::WA_OutsideWSRange, true);
if (q->isVisible())
hide_sys();
data.crect = QRect(x, y, w, h);
} else if (q->testAttribute(Qt::WA_OutsideWSRange)) {
q->setAttribute(Qt::WA_OutsideWSRange, false);
needsShow = true;
}
}
if (q->isVisible()) {
if (!q->testAttribute(Qt::WA_DontShowOnScreen)

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



