Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86544

Wrong zoom calculation causes the window position to be displayed incorrectly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.15.0
    • None
    • UOS(Deepin)
    • Linux/X11

    Description

      Scenario:

         qputenv("QT_SCALE_FACTOR", "1.25");
        setGeometry(screen->virtualGeometry()); 
      
      inline QPoint scale(const QPoint &pos, qreal scaleFactor, QPoint origin = QPoint(0, 0))
      {
           return (pos - origin) * scaleFactor + origin;
      }

      This function is to calculate the offset of pos relative to origin? Then this is a wrong approach.

      To

      If the incoming origin is a value before scaling, then the result of (pos-origin)*scaleFactor is an "increment" after scaling, the "increment" after scaling + the origin before scaling will be wrong result. It should be correct that origin also participates in scaling. The calculation formula is (pos-origin) * scaleFactor + origin*scaleFactor. After simplification, it is pos*scaleFactor

      If origin is the value when zoomed, then using the pos before zooming-the origin after zooming is also a wrong logic

      To

      For the scaling calculation of coordinates, origin is not required

       

      In line 279 of xcbwindow.cpp, this function will be used to calculate the window size, which will cause an error in the display of the application position under dual screens

          QPainter painter(this);
          painter.setBrush(Qt::red);
          painter.drawEllipse(0,0,1000,1000);
      

      You can see that the circle drawn from 0,0 is not displayed completely. Although the geometry of the window is 0,0, the rect created in XcbWIndow is -540,0. 

      Attachments

        Activity

          People

            sorvig Morten Sørvig
            tanghaixiang haixiang tang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: