PDA

View Full Version : structure variable to Qml



mouni
1st October 2016, 14:12
i want to pass structure variable to qml file...



#ifndef MYTCPSOCKET_H
#define MYTCPSOCKET_H

#include <QObject>
#include <QTcpSocket>
#include <QAbstractSocket>
#include <QDebug>
#include <QXmlStreamReader>


typedef struct
{
int Sc_Index;
int Sc_Bitrate;
int Sc_Type;
int Sc_Language;
int Sc_Program_Type;
}ScInfo;

typedef struct
{
int bcid;
QString BcLabel;
int Bitrate;
int Sc_Count;
ScInfo sc[8];
}BcInfo;

class MyTcpSocket : public QObject
{
Q_OBJECT


public:
explicit MyTcpSocket(QObject *parent = 0);

void processBcInfo();
void processBC(BcInfo *pBcinfo);
void processSC(ScInfo *m_sScinfo);
QString readNextText();

signals:

public slots:
void connected();
void disconnected();
void hostFound();
void bytesWritten(qint64 bytes);
void readyRead();
void error(QAbstractSocket::SocketError socketError);
void read();

private:
QTcpSocket * socket;
QByteArray m_bWriteArray;
QByteArray m_bReadArray;
const char *m_np1;
QStringList myStringList;
QString m_sdatastring;
QString m_srequestString;
QXmlStreamReader xml;
bool nLastElement;

};

#endif // MYTCPSOCKET_H




ListView
{
width: 200
height: 200

ListModel
{
id: mainModel
ListElement
{
name:"YazmiAud" // instead of this BcLabel; here
}
}
model: mainModel
delegate: Column
{
Text
{
text: name
}

}


BcLabel i want to give to listelement name in qt any body give the solution

anda_skoa
1st October 2016, 16:07
I am afraid I don't understand what you are asking for.

The C++ code has no connection to the QML code in any way.
Also a ListElement is a primitive data structure, its properties can only hold literals and can't be bound to more complex expressions.

Cheers,
_