Hi,
I read the values from XML file and store it in the object, and the object stored in the Qlist. Now I want to now how to assign the Qlist to Listview in qml?
HomeController.h:
-----------------------
struct PortalMapItemInfo {
};
class HomeController
: public QObject{
Q_OBJECT
public:
Q_INVOKABLE bool eveReadXML();
}
struct PortalMapItemInfo {
QString pstrTitle;
QString pstrItemId;
QString pstrDescription;
QString pstrCreated;
};
class HomeController : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE bool eveReadXML();
}
To copy to clipboard, switch view to plain text mode
HomeController.CPP:
-----------------------
void HomeController::eveReadXML()
{
//Read the xml Value and load it the object of the class
PortalMapItemInfo obj;
obj.pstrTitle = strTitle;
obj.pstrItemId = strItemId;
obj.pstrDescription = strDescription;
obj.pstrCreated = strCreated;
QList<PortalMapItemInfo> datalist;
datalist << obj; //Values are properly binded.
}
void HomeController::eveReadXML()
{
//Read the xml Value and load it the object of the class
PortalMapItemInfo obj;
obj.pstrTitle = strTitle;
obj.pstrItemId = strItemId;
obj.pstrDescription = strDescription;
obj.pstrCreated = strCreated;
QList<PortalMapItemInfo> datalist;
datalist << obj; //Values are properly binded.
}
To copy to clipboard, switch view to plain text mode
ListPortalItem.Qml
--------------------
ListView {
id: idListView
anchors {
left: parent.left
leftMargin: 10 * scaleFactor
right: parent.right
rightMargin: 10 * scaleFactor
top: rectangleToolBar.bottom
topMargin: 10 * scaleFactor
bottom: rectangleStatusBar.top
bottomMargin: 10 * scaleFactor
}
// model:???????????????????????????
delegate: comsearchDelegate
spacing: 10 * scaleFactor
clip: true
}
Component {
id: comsearchDelegate
Row {
spacing: 10 * scaleFactor
Image {
id: imageItem
width: 100 * scaleFactor
height: 70 * scaleFactor
source: thumbnailUrl
}
Column {
Layout.alignment: Qt.AlignTop
Text { text: title; font { pixelSize: 14 * scaleFactor; bold: true } }
}
}
}
ListView {
id: idListView
anchors {
left: parent.left
leftMargin: 10 * scaleFactor
right: parent.right
rightMargin: 10 * scaleFactor
top: rectangleToolBar.bottom
topMargin: 10 * scaleFactor
bottom: rectangleStatusBar.top
bottomMargin: 10 * scaleFactor
}
// model:???????????????????????????
delegate: comsearchDelegate
spacing: 10 * scaleFactor
clip: true
}
Component {
id: comsearchDelegate
Row {
spacing: 10 * scaleFactor
Image {
id: imageItem
width: 100 * scaleFactor
height: 70 * scaleFactor
source: thumbnailUrl
}
Column {
Layout.alignment: Qt.AlignTop
Text { text: title; font { pixelSize: 14 * scaleFactor; bold: true } }
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks