Quantcast
Channel: Active questions tagged qtquick2 - Stack Overflow
Viewing all articles
Browse latest Browse all 137

QML layout and padding working in Qt Design Studio but not Qt Creator with Python

$
0
0

I have the following QML code:

import QtQuickimport QtQuick.Windowimport QtQuick.Controlsimport QtQuick.LayoutsWindow {    visible: true    width: 300    height: 300    title: "Padding test"    Frame {        anchors.centerIn: parent        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"                }            }        }    }}

In Qt Design Studio

In Qt Design Studio, this code works just as I would expect. It produces this:

enter image description here

I am using Qt Design Studio 4.5.1, which according to the document Finding the Qt Runtime Version means that it is using Qt 6.6.2.

In Qt Creator

In Qt Creator, the exact same code produces this:

enter image description here

which is not what I would expect. I am using Qt Creator 13.0.2. The application is in Python, and not C++, and so I am using PySide6, which appears to be using Qt 6.7.2.

The Python code that launches this is in Python 3.12.1 and is:

import sysfrom pathlib import Pathfrom PySide6.QtGui import QGuiApplicationfrom PySide6.QtQml import QQmlApplicationEngineif __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())

Questions

  1. Why is there a difference between these two methods?
  2. Is there something missing in the Python setup that is not loading some component of QML?

There's not a way that I know of to make Qt Design Studio using Qt 6.7, so I have no way of knowing if it's a versioning problem. However, that would be very disturbing indeed. Hopefully there is something simple here. My only guess is that this is a Qt bug or there is some "QML component" I can load into the engine from Python.

Thank you for any help!


Viewing all articles
Browse latest Browse all 137

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>