Qml ListView ComboBox
Добрый день!
Создал ListView с делегатом в который входит ComBoBox
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle{ anchors.fill: parent ListModel { id: fruitModel ListElement { name: "Apple" cost: 2.45 } ListElement { name: "Orange" cost: 3.25 } ListElement { name: "Banana" cost: 1.95 } } Component { id: fruitDelegate Item { width: 200; height: 50 Rectangle{ id:firstRec width: 80 height: 33 anchors.left: parent Text { id: nameField; text: name } } Rectangle{ id:secondRec anchors.left:firstRec.right width: 80 height: 33 Text { text: '$' + cost; anchors.left: nameField.right } } ComboBox{ id:comb anchors.left: secondRec.right model: [2.45, 3.25, 3.25] } } } ListView { anchors.fill: parent model: fruitModel delegate: fruitDelegate } }
}
Подскажите пожалуста как выставить значение в комбобоксах соответственно модели fruitModel?
(например во второй строчке ListView - значение Combobox - 3.25 . А выподающий список согласно его модели )
И как узнать текущее значение ComboBox ?
Заранее спасибо!
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.Do you like it? Share on social networks!
- Дмитрий
- May 7, 2024, 9:40 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:60points,
- Rating points-1
d
- dsfs
- April 26, 2024, 4:56 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:80points,
- Rating points4
Last comments
Qt Linux - Lesson 001. Autorun Qt application under Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
АК
Qt WinAPI - Lesson 007. Working with ICMP Ping in Qt Без строки #include <QRegularExpressionValidator> в заголовочном файле не работает валидатор.
Анатолий КононенкоFeb. 5, 2024, 1:50 a.m.
EVADec. 25, 2023, 10:30 a.m.
Boost - static linking in CMake project under Windows Сделал всё по-как у вас, но выдаёт ошибку [build] LINK : fatal error LNK1104: не удается открыть файл "libboost_locale-vc142-mt-gd-x64-1_74.lib" Хоть убей, не могу понять в чём дел…
Qt/C++ - Lesson 056. Connecting the Boost library in Qt for MinGW and MSVC compilers Для решения твой проблемы добавь в файл .pro строчку "LIBS += -lws2_32" она решит проблему , лично мне помогло.
Now discuss on the forum
добавить qlineseries в функции в функции: "GPlotter::addSeries(QString title, QVector &arr)" я вызываю метод setChart(...), я в конструктор передал адрес на QChartView элемент
BlinCTMay 5, 2024, 5:46 a.m.
Best Indian Food Restaurant In Cincinnati OH Ready to embark on a gastronomic journey like no other? Join us at App india restaurant and discover why we're renowned as the Best Indian Food Restaurant In Cincinnati OH . Whether y…
Evgenii LegotckoiMay 2, 2024, 2:07 p.m.
IscanderCheApril 30, 2024, 4:22 a.m.
добрый, можете в делегате обьявить переменную, в которую будет писать комбобокс свое значение. а потом по индексу модели дергать данное значение, ну или непосредственно дергать сам комбобокс по индексу модели