Skip to content

Commit

Permalink
修复水平方向向左拖动窗口,但是高度异常缩小的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
HuaGouFdog committed Jun 18, 2024
1 parent bcdfd38 commit 72b6944
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions source/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ MainWindow::MainWindow(QWidget *parent) :
//打开数据库
db_ = new sqlhandle();

dlwidget = new downloadwidget(ui->toolButton_download);
}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -361,27 +360,27 @@ void MainWindow::updateWindowSize()
int delValue_Y = m_startPoint.y() - m_endPoint.y();
int m_windowMinWidth = 600;
int m_windowMinHeight = 600;
if (m_stretchRectState == LEFT_BORDER)
{
if (m_stretchRectState == LEFT_BORDER) {
//qDebug() << "更新窗口大小 this->geometry().width() = "<< this->geometry().width() << " delValue_X= " << delValue_X;
if (this->geometry().width() <= m_windowMinWidth && delValue_X <= 0) {
//qDebug() << "已经达到最小值 delValue_X=" << delValue_X;
return;
}
QPoint topLeftPoint = windowRect.topLeft();
topLeftPoint.setX(topLeftPoint.x() - delValue_X);
windowRect.setBottomLeft(topLeftPoint);
QPoint bottomLeftPoint = windowRect.bottomLeft();
bottomLeftPoint.setX(bottomLeftPoint.x() - delValue_X);
windowRect.setBottomLeft(bottomLeftPoint);
//qDebug() << "走这里";
//qDebug() << "当前高度" << this->geometry().height();
//qDebug() << "windowRect = " << windowRect;
this->setGeometry(windowRect);
}
else if (m_stretchRectState == RIGHT_BORDER)
{
//qDebug() << "现在高度" << this->geometry().height();

} else if (m_stretchRectState == RIGHT_BORDER) {
QPoint bottomRightPoint = windowRect.bottomRight();
bottomRightPoint.setX(bottomRightPoint.x() - delValue_X);
windowRect.setBottomRight(bottomRightPoint);
this->setGeometry(windowRect);
}
else if (m_stretchRectState == TOP_BORDER)
{
} else if (m_stretchRectState == TOP_BORDER) {
if (this->geometry().height() <= m_windowMinHeight && delValue_Y <= 0) {
//qDebug() << "已经达到最小值 delValue_Y=" << delValue_Y;
return;
Expand All @@ -390,17 +389,13 @@ void MainWindow::updateWindowSize()
topLeftPoint.setY(topLeftPoint.y() - delValue_Y);
windowRect.setTopLeft(topLeftPoint);
this->setGeometry(windowRect);
}
else if (m_stretchRectState == BOTTOM_BORDER)
{
} else if (m_stretchRectState == BOTTOM_BORDER) {
//qDebug() << "下边BOTTOM_BORDER";
QPoint bottomRightPoint = windowRect.bottomRight();
bottomRightPoint.setY(bottomRightPoint.y() - delValue_Y);
windowRect.setBottomRight(bottomRightPoint);
this->setGeometry(windowRect);
}
else if (m_stretchRectState == LEFT_TOP_RECT)
{
} else if (m_stretchRectState == LEFT_TOP_RECT) {
//qDebug() << "更新窗口大小 this->geometry().width() = "<< this->geometry().width() << " delValue_X= " << delValue_X;
//qDebug() << "更新窗口大小 this->geometry().height() = "<< this->geometry().height() << " delValue_Y= " << delValue_Y;
if (this->geometry().width() - 3 <= m_windowMinWidth && delValue_X <= 0
Expand Down Expand Up @@ -443,9 +438,7 @@ void MainWindow::updateWindowSize()
this->setGeometry(windowRect);
}
//qDebug() << " windowRect3 = " << this->geometry();
}
else if (m_stretchRectState == RIGHT_TOP_RECT)
{
} else if (m_stretchRectState == RIGHT_TOP_RECT) {
if (this->geometry().width() - 3 <= m_windowMinWidth && delValue_X <= 0
&& this->geometry().height() -3 <= m_windowMinHeight && delValue_Y <= 0) {
//qDebug() << "已经达到最小值 delValue_X=" << delValue_X;
Expand Down Expand Up @@ -490,17 +483,13 @@ void MainWindow::updateWindowSize()
// topRightPoint.setY(topRightPoint.y() - delValue_Y);
// windowRect.setTopRight(topRightPoint);
// this->setGeometry(windowRect);
}
else if (m_stretchRectState == RIGHT_BOTTOM_RECT)
{
} else if (m_stretchRectState == RIGHT_BOTTOM_RECT) {
QPoint bottomRightPoint = windowRect.bottomRight();
bottomRightPoint.setX(bottomRightPoint.x() - delValue_X);
bottomRightPoint.setY(bottomRightPoint.y() - delValue_Y);
windowRect.setBottomRight(bottomRightPoint);
this->setGeometry(windowRect);
}
else if (m_stretchRectState == LEFT_BOTTOM_RECT)
{
} else if (m_stretchRectState == LEFT_BOTTOM_RECT) {
if (this->geometry().width() - 3 <= m_windowMinWidth && delValue_X <= 0
&& this->geometry().height() -3 <= m_windowMinHeight && delValue_Y <= 0) {
//qDebug() << "已经达到最小值 delValue_X=" << delValue_X;
Expand Down

0 comments on commit 72b6944

Please sign in to comment.