void center(QWidget & widget) { QRect windowSize = QApplication::desktop() -> frameGeometry(); int x = (windowSize.width() - widget.frameGeometry().width()) / 2; int y = (windowSize.height() - widget.frameGeometry().height()) / 2; widget.move(x, y); }
QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) { QWidget *widget = QWidget::find(window); if (!widget) return QPixmap(); QRect grabRect = widget->frameGeometry(); if (!widget->isWindow()) grabRect.translate(widget->parentWidget()->mapToGlobal(QPoint())); if (w < 0) w = widget->width() - x; if (h < 0) h = widget->height() - y; grabRect &= QRect(x, y, w, h).translated(widget->mapToGlobal(QPoint())); QScreen *screen = qt_screen; QDesktopWidget *desktop = QApplication::desktop(); if (!desktop) return QPixmap(); if (desktop->numScreens() > 1) { const int screenNo = desktop->screenNumber(widget); if (screenNo != -1) screen = qt_screen->subScreens().at(screenNo); grabRect = grabRect.translated(-screen->region().boundingRect().topLeft()); } if (screen->pixelFormat() == QImage::Format_Invalid) { qWarning("QPixmap::grabWindow(): Unable to copy pixels from framebuffer"); return QPixmap(); } if (screen->isTransformed()) { const QSize screenSize(screen->width(), screen->height()); grabRect = screen->mapToDevice(grabRect, screenSize); } QWSDisplay::grab(false); QPixmap pixmap; QImage img(screen->base(), screen->deviceWidth(), screen->deviceHeight(), screen->linestep(), screen->pixelFormat()); img = img.copy(grabRect); QWSDisplay::ungrab(); if (screen->isTransformed()) { QMatrix matrix; switch (screen->transformOrientation()) { case 1: matrix.rotate(90); break; case 2: matrix.rotate(180); break; case 3: matrix.rotate(270); break; default: break; } img = img.transformed(matrix); } if (screen->pixelType() == QScreen::BGRPixel) img = img.rgbSwapped(); return QPixmap::fromImage(img); }
void NcWidgetData::handleMousePressEvent( QMouseEvent* event ) { if ( event->button() == Qt::LeftButton ) { mLeftButtonPressed = true; QRect frameRect = mWidget->frameGeometry(); mPressedMousePos.recalculate( event->globalPos(), frameRect ); mDragPos = event->globalPos() - frameRect.topLeft(); if ( mPressedMousePos.onEdges ) { if ( d->mUseRubberBandOnResize ) { mRubberBand->setGeometry( frameRect ); mRubberBand->show(); } } else if ( d->mUseRubberBandOnMove ) { mRubberBand->setGeometry( frameRect ); mRubberBand->show(); } } }
void GlobalSettingsConfig::transportCurrent() { QWidget* w = MusEGlobal::muse->transportWindow(); if (!w) return; QRect r(w->frameGeometry()); transportX->setValue(r.x()); transportY->setValue(r.y()); }
/*! Returns the offset of \a widget in the coordinates of this window surface. */ QPoint QWindowSurface::offset(const QWidget *widget) const { QWidget *window = d_ptr->window; QPoint offset = widget->mapTo(window, QPoint()); #ifdef Q_WS_QWS offset += window->geometry().topLeft() - window->frameGeometry().topLeft(); #endif return offset; }
/*! \reimp */ int QAccessibleApplication::childAt(int x, int y) const { const QWidgetList tlw(topLevelWidgets()); for (int i = 0; i < tlw.count(); ++i) { QWidget *w = tlw.at(i); if (w->frameGeometry().contains(x,y)) return i+1; } return -1; }
void center(QWidget &widget) { int x, y; int screenWidth; int screenHeight; QDesktopWidget *desktop = QApplication::desktop(); screenWidth = desktop->width(); screenHeight = desktop->height(); int WIDTH = widget.frameGeometry().width(); int HEIGHT = widget.frameGeometry().height(); x = (screenWidth - WIDTH) / 2; y = (screenHeight - HEIGHT) / 2; widget.move(x,y); // widget.setGeometry(x, y, WIDTH, HEIGHT); // widget.setFixedSize(WIDTH, HEIGHT); }
void GlobalSettingsConfig::mixer2Current() { QWidget* w = MusEGlobal::muse->mixer2Window(); if (!w) return; QRect r(w->frameGeometry()); mixer2X->setValue(r.x()); mixer2Y->setValue(r.y()); mixer2W->setValue(w->width()); mixer2H->setValue(w->height()); }
void GlobalSettingsConfig::bigtimeCurrent() { QWidget* w = MusEGlobal::muse->bigtimeWindow(); if (!w) return; QRect r(w->frameGeometry()); bigtimeX->setValue(r.x()); bigtimeY->setValue(r.y()); bigtimeW->setValue(w->width()); bigtimeH->setValue(w->height()); }
QSize VBoxDbgBaseWindow::vGuessBorderSizes() { #ifdef Q_WS_X11 /* (from the qt gui) */ /* only once. */ if (!m_cxBorder && !m_cyBorder) { /* On X11, there is no way to determine frame geometry (including WM * decorations) before the widget is shown for the first time. Stupidly * enumerate other top level widgets to find the thickest frame. The code * is based on the idea taken from QDialog::adjustPositionInternal(). */ int extraw = 0, extrah = 0; QWidgetList list = QApplication::topLevelWidgets(); QListIterator<QWidget*> it (list); while ((extraw == 0 || extrah == 0) && it.hasNext()) { int framew, frameh; QWidget *current = it.next(); if (!current->isVisible()) continue; framew = current->frameGeometry().width() - current->width(); frameh = current->frameGeometry().height() - current->height(); extraw = qMax (extraw, framew); extrah = qMax (extrah, frameh); } if (extraw || extrah) { m_cxBorder = extraw; m_cyBorder = extrah; } } #endif /* X11 */ return QSize(m_cxBorder, m_cyBorder); }
void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition) { #ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1 QWidget *pTopLevelWidget = window(); /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */ if (pTopLevelWidget->isMaximized()) return; /* Calculate client window offsets: */ QRect frameGeo = pTopLevelWidget->frameGeometry(); QRect geo = pTopLevelWidget->geometry(); int dl = geo.left() - frameGeo.left(); int dt = geo.top() - frameGeo.top(); int dr = frameGeo.right() - geo.right(); int db = frameGeo.bottom() - geo.bottom(); /* Get the best size w/o scroll bars: */ QSize s = pTopLevelWidget->sizeHint(); /* Resize the frame to fit the contents: */ s -= pTopLevelWidget->size(); frameGeo.setRight(frameGeo.right() + s.width()); frameGeo.setBottom(frameGeo.bottom() + s.height()); if (bAdjustPosition) { QRegion availableGeo; QDesktopWidget *dwt = QApplication::desktop(); if (dwt->isVirtualDesktop()) /* Compose complex available region */ for (int i = 0; i < dwt->numScreens(); ++ i) availableGeo += dwt->availableGeometry(i); else /* Get just a simple available rectangle */ availableGeo = dwt->availableGeometry(pTopLevelWidget->pos()); frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, vboxGlobal().vmRenderMode() != SDLMode /* can resize? */); } #if 0 /* Center the frame on the desktop: */ frameGeo.moveCenter(availableGeo.center()); #endif /* Finally, set the frame geometry */ pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db); #else /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */ Q_UNUSED(bAdjustPosition); #endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */ }
int MovableWidgetContainer::currentDropLocation(const QPoint &p) { int drop_location_index = -1; for (int i = 0; i < layout()->count(); ++i) { QLayoutItem *item = layout()->itemAt(i); QWidget *widget = item->widget(); if (widget) { if (widget->frameGeometry().contains(p)) { drop_location_index = i; break; } } } return drop_location_index; }
void TransparentPlugin::tickMouse() { #ifdef WIN32 QPoint p = QCursor::pos(); bool bMouse = false; QWidget *main = getMainWindow(); if (main && main->isVisible()){ if (main->frameGeometry().contains(p)) bMouse = true; } if (bMouse != m_bHaveMouse){ m_bHaveMouse = bMouse; setState(); } #endif }
void NcWidgetData::updateCursorShape( const QPoint& globalMousePos ) { if ( mWidget->isFullScreen() || mWidget->isMaximized() ) { if ( mCursorShapeChanged ) mWidget->unsetCursor(); return; } mMoveMousePos.recalculate( globalMousePos, mWidget->frameGeometry() ); if( mMoveMousePos.onTopLeftEdge || mMoveMousePos.onBottomRightEdge ) { mWidget->setCursor( Qt::SizeFDiagCursor ); mCursorShapeChanged = true; } else if( mMoveMousePos.onTopRightEdge || mMoveMousePos.onBottomLeftEdge ) { mWidget->setCursor( Qt::SizeBDiagCursor ); mCursorShapeChanged = true; } else if( mMoveMousePos.onLeftEdge || mMoveMousePos.onRightEdge ) { mWidget->setCursor( Qt::SizeHorCursor ); mCursorShapeChanged = true; } else if( mMoveMousePos.onTopEdge || mMoveMousePos.onBottomEdge ) { mWidget->setCursor( Qt::SizeVerCursor ); mCursorShapeChanged = true; } else { if ( mCursorShapeChanged ) { mWidget->unsetCursor(); mCursorShapeChanged = false; } } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget widget; widget.resize(400, 300); //设置窗口大小 widget.move(200, 100); //设置窗口位置 widget.show(); int x = widget.x(); qDebug("x: %d", x); //输出x的值 int y = widget.y(); qDebug("y: %d", y); QRect geometry = widget.geometry(); QRect frame = widget.frameGeometry(); qDebug() << "geometry: " << geometry << "frame: " << frame; qDebug() << "pos:" << widget.pos() << endl << "rect:" << widget.rect() << endl << "size:" << widget.size() << endl << "width:" << widget.width() << endl << "height:" << widget.height(); return a.exec(); }
void centerWindow (QWidget * widget) { QWidget *pw = widget->parentWidget(); QRect rect = pw->frameGeometry(); widget->move(rect.center() - widget->rect().center()); }
bool WindowSticker::eventFilter(QObject *AWatched, QEvent *AEvent) { if (AEvent->type() == QEvent::NonClientAreaMouseButtonPress) { QWidget *window = qobject_cast<QWidget *>(AWatched); if (window && window->isWindow()) { FCurWindow = window; } } else if (AEvent->type() == QEvent::NonClientAreaMouseButtonRelease) { FCurWindow = NULL; } else if (AEvent->type() == QEvent::NonClientAreaMouseMove) { FCurWindow = NULL; } else if (AEvent->type() == QEvent::WindowStateChange) { FCurWindow = NULL; } else if (AWatched==FCurWindow && AEvent->type()==QEvent::Move) { const int delta = 15; QPoint cursorPos = QCursor::pos(); QRect windowRect = FCurWindow->frameGeometry(); QRect desckRect = QApplication::desktop()->availableGeometry(FCurWindow); int borderTop = cursorPos.y() - windowRect.y(); int borderLeft = cursorPos.x() - windowRect.x(); int borderRight = cursorPos.x() + desckRect.right() - windowRect.right(); int borderBottom = cursorPos.y() + desckRect.bottom() - windowRect.bottom(); FStickPos = windowRect.topLeft(); if (qAbs(borderTop - cursorPos.y()) < delta) { FStickPos.setY(0); } else if (qAbs(borderBottom - cursorPos.y()) < delta) { FStickPos.setY(desckRect.bottom() - windowRect.height()); } if (qAbs(borderLeft - cursorPos.x()) < delta) { FStickPos.setX(0); } else if(qAbs(borderRight - cursorPos.x()) < delta) { FStickPos.setX(desckRect.right() - windowRect.width()); } if (FStickPos != windowRect.topLeft()) { QEvent *stickEvent = new QEvent((QEvent::Type)FStickEvent); QApplication::postEvent(AWatched,stickEvent,Qt::HighEventPriority); } } else if (FCurWindow==AWatched && AEvent->type()==FStickEvent) { FCurWindow->move(FStickPos); return true; } return QObject::eventFilter(AWatched,AEvent); }
bool ViewAreaImpl::viewTabMouseMoveEvent(ViewPane* pane, QMouseEvent* event) { if(!isViewDragging){ if(event->buttons() & Qt::LeftButton){ if((event->pos() - tabDragStartPosition).manhattanLength() > QApplication::startDragDistance()){ if(!pane->tabBar()->geometry().contains(event->pos())){ if(draggedView = pane->currentView()){ isViewDragging = true; dragSrcPane = pane; QWidget* toplevel = pane; while(toplevel->parentWidget()){ toplevel = toplevel->parentWidget(); } QSize s = toplevel->frameGeometry().size(); draggedViewWindowSize.setWidth(draggedView->width() + s.width() - toplevel->width()); draggedViewWindowSize.setHeight(draggedView->height() + s.height() - toplevel->height()); QApplication::setOverrideCursor(Qt::ClosedHandCursor); } } } } } else { ViewArea* prevViewArea = dragDestViewArea; dragDestViewArea = 0; dragDestPane = 0; // find a window other than the rubber band QPoint p = event->globalPos(); QWidget* window = 0; for(int i=0; i < 3; ++i){ window = QApplication::topLevelAt(p); if(window && !dynamic_cast<QRubberBand*>(window)){ break; } p += QPoint(-1, -1); } if(window){ dragDestViewArea = dynamic_cast<ViewArea*>(window); if(!dragDestViewArea){ if(MainWindow* mainWindow = dynamic_cast<MainWindow*>(window)){ ViewArea* viewArea = mainWindow->viewArea(); if(viewArea->rect().contains(viewArea->mapFromGlobal(event->globalPos()))){ dragDestViewArea = viewArea; } } } } if(dragDestViewArea){ QWidget* pointed = dragDestViewArea->childAt(dragDestViewArea->mapFromGlobal(event->globalPos())); while(pointed){ dragDestPane = dynamic_cast<ViewPane*>(pointed); if(dragDestPane){ dragView(event); break; } pointed = pointed->parentWidget(); } } else { dragViewOutside(event->globalPos()); } if(prevViewArea != dragDestViewArea){ if(prevViewArea){ prevViewArea->impl->rubberBand->hide(); } else { rubberBand->hide(); } } } return false; }
void VirtualKeyboardQt::SwitchLayout(const QString &lang) { if (!m_parentEdit) { VERBOSE(VB_IMPORTANT, LOC_ERR + "No edit receiving output"); reject(); return; } QString language = lang.toLower(); QString theme_file = QString("keyboard/%1_").arg(language); if (!loadThemedWindow("keyboard", theme_file)) { VERBOSE(VB_GENERAL, LOC_WARN + QString("Cannot find layout for '%1'").arg(language)); // cannot find layout so fallback to US English layout if (!loadThemedWindow("keyboard", "keyboard/en_us_")) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Cannot find layout for US English"); reject(); return; } } // get dialog size from keyboard_container area LayerSet *container = getContainer("keyboard_container"); if (!container) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Cannot find the 'keyboard_container' in your theme"); reject(); return; } m_popupWidth = container->GetAreaRect().width(); m_popupHeight = container->GetAreaRect().height(); setFixedSize(QSize(m_popupWidth, m_popupHeight)); QWidget *pw = m_parentEdit; QWidget *tlw = pw->topLevelWidget(); QRect pwg = pw->geometry(); QRect tlwg = tlw->frameGeometry(); QPoint newpos; PopupPositionQt preferredPos; if (m_parentEdit->inherits("MythLineEdit")) { MythLineEdit *par = (MythLineEdit *)m_parentEdit; preferredPos = par->getPopupPosition(); } else if (m_parentEdit->inherits("MythRemoteLineEdit")) { MythRemoteLineEdit *par = (MythRemoteLineEdit *)m_parentEdit; preferredPos = par->getPopupPosition(); } else if (m_parentEdit->inherits("MythComboBox")) { MythComboBox *par = (MythComboBox *)m_parentEdit; preferredPos = par->getPopupPosition(); } else { preferredPos = VKQT_POSCENTERDIALOG; } if (preferredPos == VKQT_POSBELOWEDIT) { if (pw->mapTo(tlw, QPoint(0,pwg.height() + m_popupHeight + 5)).y() < tlwg.height()) { newpos = QPoint(pwg.width() / 2 - m_popupWidth / 2, pwg.height() + 5); } else { newpos = QPoint(pwg.width() / 2 - m_popupWidth / 2, - 5 - m_popupHeight); } } else if (preferredPos == VKQT_POSABOVEEDIT) { if (pw->mapTo(tlw, QPoint(0, - m_popupHeight - 5)).y() > 0) { newpos = QPoint(pwg.width() / 2 - m_popupWidth / 2, - 5 - m_popupHeight); } else { newpos = QPoint(pwg.width() / 2 - m_popupWidth / 2, pwg.height() + 5); } } else if (preferredPos == VKQT_POSTOPDIALOG) { newpos = QPoint(tlwg.width() / 2 - m_popupWidth / 2, 5); this->move(newpos); } else if (preferredPos == VKQT_POSBOTTOMDIALOG) { newpos = QPoint(tlwg.width() / 2 - m_popupWidth / 2, tlwg.height() - 5 - m_popupHeight); this->move(newpos); } else if (preferredPos == VKQT_POSCENTERDIALOG) { newpos = QPoint(tlwg.width() / 2 - m_popupWidth / 2, tlwg.height() / 2 - m_popupHeight / 2); this->move(newpos); } if (preferredPos == VKQT_POSABOVEEDIT || preferredPos == VKQT_POSBELOWEDIT) { int delx = pw->mapTo(tlw,newpos).x() + m_popupWidth - tlwg.width() + 5; newpos = QPoint(newpos.x() - (delx > 0 ? delx : 0), newpos.y()); delx = pw->mapTo(tlw, newpos).x(); newpos = QPoint(newpos.x() - (delx < 0 ? delx : 0), newpos.y()); int xbase, width, ybase, height; float wmult, hmult; GetMythUI()->GetScreenSettings(xbase, width, wmult, ybase, height, hmult); newpos.setX(newpos.x() - xbase); newpos.setY(newpos.y() - ybase); this->move( pw->mapToGlobal( newpos ) ); } // find the UIKeyboardType m_keyboard = getUIKeyboardType("keyboard"); if (!m_keyboard) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Cannot find the UIKeyboardType in your theme"); reject(); return; } if (m_parentEdit->inherits("QComboBox")) { QComboBox *combo = (QComboBox *) m_parentEdit; m_keyboard->SetEdit(combo->lineEdit()); } else m_keyboard->SetEdit(m_parentEdit); m_keyboard->SetParentDialog(this); }
/*! \fn void CSizeGrip::mousePressEvent(QMouseEvent * event) Receives the mouse press events for the widget, and primes the resize operation. The mouse press event is passed in the \a event parameter. */ void CSizeGrip::mousePressEvent(QMouseEvent * e) { ungrabGesture(Qt::TapAndHoldGesture); if (e->button() != Qt::LeftButton) { QWidget::mousePressEvent(e); return; } QWidget *tlw = qt_sizegrip_topLevelWidget(); p = e->globalPos(); gotMousePress = true; r = tlw->geometry(); #ifdef Q_WS_X11 #if QT_VERSION >= 0x050000 // Use a native X11 sizegrip for "real" top-level windows if supported. if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint) && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { XEvent xev; xev.xclient.type = ClientMessage; xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE); xev.xclient.display = X11->display; xev.xclient.window = tlw->winId(); xev.xclient.format = 32; xev.xclient.data.l[0] = e->globalPos().x(); xev.xclient.data.l[1] = e->globalPos().y(); if (atBottom()) xev.xclient.data.l[2] = atLeft() ? 6 : 4; // bottomleft/bottomright else xev.xclient.data.l[2] = atLeft() ? 0 : 2; // topleft/topright xev.xclient.data.l[3] = Button1; xev.xclient.data.l[4] = 0; XUngrabPointer(X11->display, X11->time); XSendEvent(X11->display, QX11Info::appRootWindow(x11Info().screen()), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); return; } #endif #endif // Q_WS_X11 #ifdef Q_WS_WIN #if QT_VERSION >= 0x050000 if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { uint orientation = 0; if (atBottom()) orientation = atLeft() ? SZ_SIZEBOTTOMLEFT : SZ_SIZEBOTTOMRIGHT; else orientation = atLeft() ? SZ_SIZETOPLEFT : SZ_SIZETOPRIGHT; ReleaseCapture(); PostMessage(tlw->winId(), WM_SYSCOMMAND, orientation, 0); return; } #endif #endif // Q_WS_WIN // Find available desktop/workspace geometry. QRect availableGeometry; bool hasVerticalSizeConstraint = true; bool hasHorizontalSizeConstraint = true; if (tlw->isWindow()) availableGeometry = QApplication::desktop()->availableGeometry(tlw); else { const QWidget *tlwParent = tlw->parentWidget(); // Check if tlw is inside QAbstractScrollArea/QScrollArea. // If that's the case tlw->parentWidget() will return the viewport // and tlw->parentWidget()->parentWidget() will return the scroll area. #ifndef QT_NO_SCROLLAREA QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(tlwParent->parentWidget()); if (scrollArea) { hasHorizontalSizeConstraint = scrollArea->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff; hasVerticalSizeConstraint = scrollArea->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff; } #endif // QT_NO_SCROLLAREA availableGeometry = tlwParent->contentsRect(); } // Find frame geometries, title bar height, and decoration sizes. const QRect frameGeometry = tlw->frameGeometry(); const int titleBarHeight = qMax(tlw->geometry().y() - frameGeometry.y(), 0); const int bottomDecoration = qMax(frameGeometry.height() - tlw->height() - titleBarHeight, 0); const int leftRightDecoration = qMax((frameGeometry.width() - tlw->width()) / 2, 0); // Determine dyMax depending on whether the sizegrip is at the bottom // of the widget or not. if (atBottom()) { if (hasVerticalSizeConstraint) dyMax = availableGeometry.bottom() - r.bottom() - bottomDecoration; else dyMax = INT_MAX; } else { if (hasVerticalSizeConstraint) dyMax = availableGeometry.y() - r.y() + titleBarHeight; else dyMax = -INT_MAX; } // In RTL mode, the size grip is to the left; find dxMax from the desktop/workspace // geometry, the size grip geometry and the width of the decoration. if (atLeft()) { if (hasHorizontalSizeConstraint) dxMax = availableGeometry.x() - r.x() + leftRightDecoration; else dxMax = -INT_MAX; } else { if (hasHorizontalSizeConstraint) dxMax = availableGeometry.right() - r.right() - leftRightDecoration; else dxMax = INT_MAX; } }
void NcWidgetData::resizeWidget( const QPoint& globalMousePos ) { QRect origRect; if ( d->mUseRubberBandOnResize ) origRect = mRubberBand->frameGeometry(); else origRect = mWidget->frameGeometry(); int left = origRect.left(); int top = origRect.top(); int right = origRect.right(); int bottom = origRect.bottom(); origRect.getCoords( &left, &top, &right, &bottom ); int minWidth = mWidget->minimumWidth(); int minHeight = mWidget->minimumHeight(); if ( mPressedMousePos.onTopLeftEdge ) { left = globalMousePos.x(); top = globalMousePos.y(); } else if ( mPressedMousePos.onBottomLeftEdge ) { left = globalMousePos.x(); bottom = globalMousePos.y(); } else if ( mPressedMousePos.onTopRightEdge ) { right = globalMousePos.x(); top = globalMousePos.y(); } else if ( mPressedMousePos.onBottomRightEdge ) { right = globalMousePos.x(); bottom = globalMousePos.y(); } else if ( mPressedMousePos.onLeftEdge ) { left = globalMousePos.x(); } else if ( mPressedMousePos.onRightEdge ) { right = globalMousePos.x(); } else if ( mPressedMousePos.onTopEdge ) { top = globalMousePos.y(); } else if ( mPressedMousePos.onBottomEdge ) { bottom = globalMousePos.y(); } QRect newRect( QPoint(left, top), QPoint(right, bottom) ); if ( newRect.isValid() ) { if ( minWidth > newRect.width() ) { //determine what has caused the width change. if( left != origRect.left() ) newRect.setLeft( origRect.left() ); else newRect.setRight( origRect.right() ); } if ( minHeight > newRect.height() ) { //determine what has caused the height change. if ( top != origRect.top() ) newRect.setTop( origRect.top() ); else newRect.setBottom( origRect.bottom() ); } if ( d->mUseRubberBandOnResize ) { mRubberBand->setGeometry( newRect ); } else { mWidget->setGeometry( newRect ); } } else { //qDebug() << "Calculated Rect is not valid" << newRect; } }