Important: Please read the Qt Code of Conduct -

Usage of Delegate

  • Hi,

    I want to delegate for two components so that both can be instantiate. Is it possible to have two components in a delegate.


  • @RG90 You can have one Item and inside it two Items. What exactly do you need, why would you need to do that?

  • @Eeli-K
    I want to make two components as dynamic object so that they can be dragged on screen simultaneously. I tried it but I could not see the change.. Do the two items need to be same components like Image.

  • @RG90
    As @Eeli-K said, you have to declare your composite component as an Item, which includes your sub-elements.
    Talking about dragging items on screen, you have to use the MouseArea component, which has a nice property called which gives draggable functionalities on a given element, passing its id.

    Here my example code:

    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Drag me!")
        Item {
            id: myCompositeItem
            Rectangle {
                width: 100
                height: 100
                color: "red"
            Rectangle {
                width: 100
                height: 100
                x: 250
                color: "green"
        MouseArea {
            anchors.fill: parent

    I don't know if I fully answered to your question, since you were talking about delegates.

Log in to reply