<?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[[SOLVED]A problem in ComboBox with image]]></title><description><![CDATA[<p dir="auto">Hi,<br />
i would like to place icon to the dropdown list, so I made some codes like this:</p>
<pre><code>......

model: ListModel {
        id: cbItems
        ListElement { text: ""; iconSource: "image1"}
        ListElement { text: ""; iconSource: "image2"}
    }

__dropDownStyle: MenuStyle {
            id: dropDownMenuStyle
            frame: dropDownMenuStyleFrame
//            __menuItemType: "comboboxitem"
            itemDelegate.label: Rectangle {
                width: root.width - 50
                height: root.height
                color: "transparent"
                Image {
                    id: operatorPic
                    width: height
                    height: operatorPictureHeight
                    anchors {
                        left: parent.left
                        leftMargin: 2
                        verticalCenter: parent.verticalCenter
                    }
                    source: operatorPic.height === 0 ? "" : styleData.iconSource
                }
                ITextLabel {
                    width: parent.width - operatorPic.width - 2 - 5
                    height: parent.height
                    fontSize: 20
                    fontColor: styleData.selected ? "white" : "black"
                    text: styleData.text
                    wrapMode: Text.WrapAtWordBoundaryOrAnywhere
                    horizontalAlignment: Text.AlignLeft
                    anchors.left: operatorPic.right
                    anchors.leftMargin: 5
                }
            }

            itemDelegate.background: Rectangle {
                z: 1
                opacity: 0.5
                height: root.height
                color: styleData.selected ? "#0098DF" : "transparent"
            }
    }
</code></pre>
<p dir="auto">I know <code>source: operatorPic.height === 0 ? "" : styleData.iconSource</code> does not work but I have no idea how to deal with it.</p>
<p dir="auto">Does anybody tell me how to do it?<br />
Thanks.</p>
]]></description><link>https://forum.qt.io/topic/58567/solved-a-problem-in-combobox-with-image</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 03:08:31 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/58567.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 04 Sep 2015 08:21:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED]A problem in ComboBox with image on Fri, 04 Sep 2015 09:15:24 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/beidaochuan">@<bdi>beidaochuan</bdi></a><br />
You have <code>styleData.index</code> and access to the model. Combine it and use</p>
<pre><code>source: cbItems.get(styleData.index).iconSource
</code></pre>
]]></description><link>https://forum.qt.io/post/289148</link><guid isPermaLink="true">https://forum.qt.io/post/289148</guid><dc:creator><![CDATA[p3c0]]></dc:creator><pubDate>Fri, 04 Sep 2015 09:15:24 GMT</pubDate></item></channel></rss>