Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Adding a dynamically created object to a layout
Forum Updated to NodeBB v4.3 + New Features

Adding a dynamically created object to a layout

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 503 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lsturtevant
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved