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

Frame behaves incorrectly on Windows but correctly on Ubuntu using Qt for Python via PySide6

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.7.0, 6.7.1, 6.7.2
    • PySide
    • None
    • Windows 11, Python 3.12, PySide6 6.7, Qt Creator 13.0, Qt Design Studio 4.5
    • Windows

    Description

      The following QML code just does not work as expected on Windows 11, using Python 3.12, and the latest PySide6. On Ubuntu it works as expected, and on Windows, it works as expected when using Qt Design Studio. But when using Qt Creator or just Python directly, the frame contains no padding and does not respond to any padding setting.

       

      import QtQuick
      import QtQuick.Window
      import QtQuick.Controls
      import QtQuick.Layouts
      
      Window {
          visible: true
          width: 300
          height: 300
          title: "Padding test"
      
          Frame {
              anchors.centerIn: parent
              
              padding: 20
      
              ColumnLayout {
                  spacing: 10
      
                  Label {
                      text: "Section"
                      font.pixelSize: 20
                      Layout.alignment: Qt.AlignHCenter
                  }
      
                  Repeater {
                      model: 4
      
                      delegate: Rectangle {
                          Layout.preferredWidth: 200
                          Layout.preferredHeight: 20
                          border.color: "black"
                          color: "lightBlue"
                      }
                  }
              }
          }
      } 

      On WIndows with Python and PySide6, this looks like:

       

      However, on Ubuntu 22.04 LTS with Python and PySide, the exact same QML code looks like this:

      (I made this screenshot on Windows using the same QML code as above but using Qt Design Studio, which does not use Python and PySide6. The screenshot looks a little scaled differently due to some weird Qt Design Studio scaling issue.)

      The Python code that loads this is very standard:

      import sys
      from pathlib import Path
      from PySide6.QtGui import QGuiApplication
      from PySide6.QtQml import QQmlApplicationEngine
      
      if __name__ == "__main__":
          app = QGuiApplication(sys.argv)
          engine = QQmlApplicationEngine()
          qml_file = Path(__file__).resolve().parent / "main.qml"
          engine.load(qml_file)
          if not engine.rootObjects():
              sys.exit(-1)
          sys.exit(app.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
            bmitc Blake Mitchell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes