Design of combo box in a different manner as stated.
Solved
QML and Qt Quick
-
Is it possible to design More than one combo box where combo box Code is same(can re-use the code) but list of elements(listView) are different. So can we define combo box code in one qml and use the same code where ever needed, only list of elements(listview) need to changed every where.
How this can be achieved?
eg: Combo Box 1-> Days: {Mon, Tues, Wed}
Combo Box 2 -> Year: {Jan, Feb, Mar}I dont want to write the combo box code again and again. One code for combo box and multiple code for list view.
-
hi,
@JasmineSethi said in Design of combo box in a different manner as stated.:can re-use the code
that is one of root concepts in QML and programming in general
MyCombo.qml
import QtQuick 2.0 import QtQuick.Controls 2.4 import QtQuick.Controls.Styles 1.4 ComboBox { background: Rectangle{ color: "lightblue" } width: 100 }
main.qml
import QtQuick 2.12 import QtQuick.Window 2.2 import QtQuick.Controls 2.4 Window { visible: true width: 640 height: 480 Row{ MyCombo{ model: ["Mon","Tues","Wed"] } MyCombo{ model: ["Jan","Meb","Mar"] } } }