Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5.4, 6.6.2, 6.7.0 Beta3
-
None
-
Windows 10 22H2, MSVC 2019 x64
-
bad5a7ac1 (dev), 56de91bec (6.7), a57e772ea (6.6), a74a8b828 (tqtc/lts-6.5)
Description
Code
Adapted from https://doc.qt.io/qt-6/qml-qtquick-controls-popup.html#popup-sizing
// RootItem.qml import QtQuick import QtQuick.Controls.Basic Item { id: root width: 640 height: 480 property double scaleFactor: 2.0 Scale { id: scale xScale: root.scaleFactor yScale: root.scaleFactor } Item { id: scaledContent transform: scale ComboBox { id: combobox model: ["Alpha", "Bravo", "Charlie"] } } Overlay.overlay.transform: scale // CRASH! Component.onCompleted: { // Still cannot assign/bind here. Component is NOT complete! console.log("Overlay is", Overlay.overlay) // "Overlay is null" //// WORKAROUND OK // Qt.callLater(function(){ // console.log("Overlay is", Overlay.overlay) // "Overlay is QQuickOverlay(...)" // Overlay.overlay.transform = scale // }) } }
// main.cpp #include <QGuiApplication> #include <QQuickView> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQuickView view(QUrl("qrc:/RootItem.qml")); view.show(); return app.exec(); }
Workaround
Don't bind the value declaratively. Assign it one event loop iteration AFTER the Component.completed signal is emitted.
(We cannot do it directly inside the Component.onCompleted handler because Overlay.overlay is still null then ("TypeError: Value is null and could not be converted to an object")