Results 1 to 2 of 2

Thread: structure variable to Qml

  1. #1
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default structure variable to Qml

    i want to pass structure variable to qml file...

    Qt Code:
    1. #ifndef MYTCPSOCKET_H
    2. #define MYTCPSOCKET_H
    3.  
    4. #include <QObject>
    5. #include <QTcpSocket>
    6. #include <QAbstractSocket>
    7. #include <QDebug>
    8. #include <QXmlStreamReader>
    9.  
    10.  
    11. typedef struct
    12. {
    13. int Sc_Index;
    14. int Sc_Bitrate;
    15. int Sc_Type;
    16. int Sc_Language;
    17. int Sc_Program_Type;
    18. }ScInfo;
    19.  
    20. typedef struct
    21. {
    22. int bcid;
    23. QString BcLabel;
    24. int Bitrate;
    25. int Sc_Count;
    26. ScInfo sc[8];
    27. }BcInfo;
    28.  
    29. class MyTcpSocket : public QObject
    30. {
    31. Q_OBJECT
    32.  
    33.  
    34. public:
    35. explicit MyTcpSocket(QObject *parent = 0);
    36.  
    37. void processBcInfo();
    38. void processBC(BcInfo *pBcinfo);
    39. void processSC(ScInfo *m_sScinfo);
    40. QString readNextText();
    41.  
    42. signals:
    43.  
    44. public slots:
    45. void connected();
    46. void disconnected();
    47. void hostFound();
    48. void bytesWritten(qint64 bytes);
    49. void readyRead();
    50. void error(QAbstractSocket::SocketError socketError);
    51. void read();
    52.  
    53. private:
    54. QTcpSocket * socket;
    55. QByteArray m_bWriteArray;
    56. QByteArray m_bReadArray;
    57. const char *m_np1;
    58. QStringList myStringList;
    59. QString m_sdatastring;
    60. QString m_srequestString;
    61. QXmlStreamReader xml;
    62. bool nLastElement;
    63.  
    64. };
    65.  
    66. #endif // MYTCPSOCKET_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ListView
    2. {
    3. width: 200
    4. height: 200
    5.  
    6. ListModel
    7. {
    8. id: mainModel
    9. ListElement
    10. {
    11. name:"YazmiAud" // instead of this BcLabel; here
    12. }
    13. }
    14. model: mainModel
    15. delegate: Column
    16. {
    17. Text
    18. {
    19. text: name
    20. }
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

    BcLabel i want to give to listelement name in qt any body give the solution
    Last edited by anda_skoa; 1st October 2016 at 15:04. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: structure variable to Qml

    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,
    _

Similar Threads

  1. Variable variable names
    By KeineAhnung in forum Newbie
    Replies: 2
    Last Post: 22nd June 2014, 19:00
  2. QtQuick structure
    By codeman in forum Qt Quick
    Replies: 4
    Last Post: 21st May 2013, 10:35
  3. Replies: 12
    Last Post: 26th June 2011, 11:26
  4. Tree structure
    By ikm in forum Newbie
    Replies: 1
    Last Post: 7th August 2009, 20:19
  5. Structure and pointers
    By zorro68 in forum General Programming
    Replies: 3
    Last Post: 22nd October 2007, 14:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.