i have tow c++ data model like this :
post data model:
class post_data_model
: public QObject{
Q_OBJECT
public:
explicit post_data_model
(QObject *parent
= 0);
Q_PROPERTY(QString key READ key WRITE set_key
) Q_PROPERTY(QString text READ text WRITE set_text
) Q_PROPERTY(QString raw_text READ raw_text WRITE set_raw_text
)
void set_raw_text
(QString raw_text
);
void set_tags
(QList <QObject
*> tags
);
private:
QList <QObject
*> m_tags;
}
class post_data_model : public QObject
{
Q_OBJECT
public:
explicit post_data_model(QObject *parent = 0);
Q_PROPERTY(QString key READ key WRITE set_key)
Q_PROPERTY(QString text READ text WRITE set_text)
Q_PROPERTY(QString raw_text READ raw_text WRITE set_raw_text)
Q_PROPERTY(QVariant tags READ tags)
void set_key(QString key);
void set_text(QString text);
void set_raw_text(QString raw_text);
void set_tags(QList <QObject *> tags);
QString key();
QVariant tags();
QString text();
QString raw_text();
private:
QString m_key;
QList <QObject *> m_tags;
QString m_text;
QString m_raw_text;
}
To copy to clipboard, switch view to plain text mode
and,tag data model :
{
Q_OBJECT
public:
explicit tags_model
(QObject *parent
= 0);
Q_PROPERTY(QString key READ key WRITE set_key
) Q_PROPERTY(QString name READ name WRITE set_name
)
private:
class tags_model : public QObject
{
Q_OBJECT
public:
explicit tags_model(QObject *parent = 0);
Q_PROPERTY(QString key READ key WRITE set_key)
Q_PROPERTY(QString name READ name WRITE set_name)
void set_key(QString key);
void set_name(QString name);
QString key();
QString name();
private:
QString m_key;
QString m_name;
To copy to clipboard, switch view to plain text mode
QML Code :
import QtQuck 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
Window {
id:container_window
visible: true
width: 360
height: 360
color: "#E6E7E7"
property bool get_profile_status :false
onActiveChanged:
{
if (get_profile_status==false)
{
Posts_Action.get_posts_stream();
get_profile_status=true
}
}
ListView
{
id:posts_list_view
height: 200
width: 200
spacing: 5
clip: true
delegate: posts_delegate
}
Component
{
id: posts_delegate
Item {
height: 150
Text {
id: post_content_txt
width: 200
wrapMode: Text.WordWrap
anchors.topMargin: 10
text: qsTr(modelData.text)
}
//Tags : No idea
//How Can show list of tags?
}
}
Item {
id: exteras
Connections
{
target:Posts_Action
onParsfinished:
{
posts_list_view.model=Posts_Action.post_list();
}
onNetwork_error_occurred :
{
console.log("ERROR: " + error_message);
}
}
}
import QtQuck 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
Window {
id:container_window
visible: true
width: 360
height: 360
color: "#E6E7E7"
property bool get_profile_status :false
onActiveChanged:
{
if (get_profile_status==false)
{
Posts_Action.get_posts_stream();
get_profile_status=true
}
}
ListView
{
id:posts_list_view
height: 200
width: 200
spacing: 5
clip: true
delegate: posts_delegate
}
Component
{
id: posts_delegate
Item {
height: 150
Text {
id: post_content_txt
width: 200
wrapMode: Text.WordWrap
anchors.topMargin: 10
text: qsTr(modelData.text)
}
//Tags : No idea
//How Can show list of tags?
}
}
Item {
id: exteras
Connections
{
target:Posts_Action
onParsfinished:
{
posts_list_view.model=Posts_Action.post_list();
}
onNetwork_error_occurred :
{
console.log("ERROR: " + error_message);
}
}
}
To copy to clipboard, switch view to plain text mode
i can use the property of post model in QML such as the key and text but the point is that i cannot have access to the list of tags...
now,how can i show the list of post tags in QML?
Bookmarks