Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2811

Title bar captured incorrectly after changing window width

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.7.2
    • PySide
    • None
    • Windows

    Description

      The following code snapshots the title bar incorrectly in the second and third try. Images available at https://stackoverflow.com/q/78717054.

      from PySide6.QtCore import QTimer
      from PySide6.QtWidgets import QApplication, QMainWindow
      
      application = QApplication()
      window = QMainWindow()
      window.show()
      screen = window.screen()
      
      def save_titlebar(filename: str) -> None:
          window.screen().grabWindow(
              window.winId(),
              x=window.frameGeometry().x() - window.geometry().x(),
              y=window.frameGeometry().y() - window.geometry().y(),
              w=window.frameGeometry().width(),
              h=window.frameGeometry().height() - window.geometry().height(),
          ).save(filename)
      
      def set_width_and_save(width: int) -> None:
          window.setFixedWidth(width)
          QTimer.singleShot(500, lambda: save_titlebar(f"titlebar{width}.png"))
      
      QTimer.singleShot(1000, lambda: set_width_and_save(400))
      QTimer.singleShot(2000, lambda: set_width_and_save(500))
      QTimer.singleShot(3000, lambda: set_width_and_save(300))
      QTimer.singleShot(4000, window.close)
      application.exec()
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            bers bers bers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes