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. Dynamic created buttons change content of other dynamic created elements
Qt 6.11 is out! See what's new in the release blog

Dynamic created buttons change content of other dynamic created elements

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.2k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello

    With the help of the forum I dynamically created some buttons which I assigned a function to a property..
    Now, inside this function, I would like to refer to other Items which are also dynamically created.

    The (pseudo)code currently looks something like this:

    @
    property var money_back: { '50e': 0,
    '20e': 0,
    '10e': 0,
    '5e': 0,
    '2e': 0,
    '1e': 0,
    '50c': 0,
    '20c': 0,
    '10c': 0,
    '5c': 0,
    '2c': 0,
    '1c': 0 };
    Row{
    id:money_row
    spacing: 5

        Component.onCompleted: {
            var button = Qt.createComponent("BubbleButton.qml");
            var selected = Qt.createComponent("ChangeText.qml");
            for (var prop in change_screen.money_back){
                selected.createObject(money_row,{
                                          "id": "selected_"+prop,
                                          "selected": "0"
                                        });
                button.createObject(money_row,{
                                                "id": "button_"+prop,
                                                "action": [function(){ selected_50e.selected += 1; }],
                                                //"ps": ps,
                                                "img_id.source": prop+".png",
                                                "img_id.align": "center",
                                                "color": "transparent"
                                            });
            }
        }@
    

    What I want to do in the end is the following: create Buttons for each coin/note and when clicked on, I want to change the content of the Text.. like a counter, how many times I clicked on a Button.

    Is there an easier way than going down the road with signals and such? (looks complicated)

    thank you for your time and help
    -m

    1 Reply Last reply
    0

    • Login

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