Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Adding a dynamically created object to a layout
lsturtevant last edited by
I am dynamically creating an object which is working fine. I set the parent of the object to a GridLayout. That also works fine. I want to set the Layout's attached properties of my object, but it's not working. Here's a small sample
var component; var button; component = Qt.createComponent("CustomButton.qml"); button = component.createObject(gridLayout); button.Layout.maximumWidth = 10; button.Layout.maximumHeight = 10;
I get the error "TypeError: Type error". The button that I properly created and I can see it and use it in the gui. If I comment out setting the maximum width and height, everything works except the size is not what I want.
It looks like the button is not getting the Layout attached property when I dynamically create it. When I create it statically in a qml file, everything works fine.
Any help would be greatly appreciated.