Why doesn't ComboBox show the Selected Item?

后端 未结 1 834
滥情空心
滥情空心 2020-12-22 09:16

Here\'s what I\'ve in my QML:

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3

Window {
    visible: tru         


        
相关标签:
1条回答
  • 2020-12-22 09:20

    For that I've to use the additional contentItem outside the ItemDelegate like this:

    contentItem: RowLayout{
        Text{ text: model[control.currentIndex].name }
        Text{
            text: " | " + model[control.currentIndex].age
            horizontalAlignment: Text.AlignRight
            Layout.fillWidth: true
        }
    }
    

    and I've to give the ComboBox an id, here in the example control is the id

    0 讨论(0)
提交回复
热议问题