简体   繁体   English

Qt应用程序几何形状宽度太大

[英]Qt app geometry width too big

I nuked the default window from my GUI app and tried to re-implement things like maximize when dragging window to top and dragging it left and right to take half a screen. 我从GUI应用程序中删除了默认窗口,并尝试重新实现诸如将窗口拖动到顶部并左右拖动以占据半个屏幕时的最大化之类的功能。

The latter is giving me some problems, the width of the app is not half the screen but more than that (like 100px more). 后者给我带来了一些问题,应用程序的宽度不是屏幕的一半,而是更多(例如100px)。 The height is good tho. 高度很好。

void MainWindow::mouseReleaseEvent(QMouseEvent *event) {
  QPoint curPos = event->globalPos();
  if (this->ui->labelTitle->underMouse()) //we grabbed the top bar
  {
    if (curPos.x()<2) //x below 2px, left side of screen
    {
          this->setGeometry(QRect(
                                QPoint(0,0), //top-left
                                QSize(
                                    QApplication::desktop()->availableGeometry().right()/2, 
                                    QApplication::desktop()->availableGeometry().bottom())));
    }
    QWidget::mouseReleaseEvent(event);
}

My screen res is 1600x900 .right() is 1599 and .right()/2 is 799 but the actual app width becomes 900 for some reason. 我的屏幕分辨率为1600x900 .right()为1599和.right()/2为799,但由于某些原因,实际的应用宽度变为900。 Where am I failing? 我在哪里失败?

问题是窗口最小大小策略设置为900px。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM