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

Title bar captured incorrectly after changing window width

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.2
    • GUI: Window management
    • 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

            owolff Oliver Wolff
            bers bers bers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes