<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Topics tagged with fil]]></title><description><![CDATA[A list of topics that have been tagged with fil]]></description><link>https://forum.qt.io/tags/fil</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 23:12:12 GMT</lastBuildDate><atom:link href="https://forum.qt.io/tags/fil.rss" rel="self" type="application/rss+xml"/><pubDate>Invalid Date</pubDate><ttl>60</ttl><item><title><![CDATA[How to put Delegates at work in *.ui.qml files?]]></title><description><![CDATA[This is  the (admittedly messy) solution I've got so far.
As I was unable to send a signal from UI file (altough QtQuick Designer accepts its declaration), I resorted to a variable registering the index of last clicked item:
// file: SettingsPageForm.ui.qml
Item {

    property int clickIndex: -1
    // ....

    ListView {
        // ...
        model: dbSettingsModel

        delegate:  Item {
            // UI graphics stuff with model.name, model,value etc...
            // ...
            // the delegate sets the index, the handler will reset it to -1
            MouseArea { onClicked: clickIndex = model.index }
        }
    }


}


The implementation logic watches for the change signal:
// file: settingsPage.qml
SettingsPageForm {

    ...

    function launchEditor( index )
    {
        // getRole( row, roleName) was added to C++ model because 
        // model properties are available inside the delegate only
        editor.title =    dbSettingsModel.getRole( index, "name"     )
        editor.value =    dbSettingsModel.getRole( index, "value"    )
        editor.unit =     dbSettingsModel.getRole( index, "unit"     )
        editor.minValue = dbSettingsModel.getRole( index, "minValue" )
        editor.maxValue = dbSettingsModel.getRole( index, "maxValue" )
        editor.open()
    }

    onClickIndexChanged:  {
        if ( clickIndex &gt;= 0 )
            launchEditor( clickIndex )
        clickIndex = -1
    }
}


I found no other way but to expand the C++ model (dbSettingsModel) with getRole( index, roleName), as model properties are not available outside delegates.
Overall it works, but I feel I'm overcomplicating it, I fell there must be a much cleaner way taking advantage of delegates straight inside UI deisgner.
]]></description><link>https://forum.qt.io/topic/145982/how-to-put-delegates-at-work-in-ui-qml-files</link><guid isPermaLink="true">https://forum.qt.io/topic/145982/how-to-put-delegates-at-work-in-ui-qml-files</guid><dc:creator><![CDATA[ellipse]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>