Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6769551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:12:25+00:00 2026-05-26T15:12:25+00:00

What I have in my project is the binary file that contains list of

  • 0

What I have in my project is the binary file that contains list of structure elements:

typedef struct {
    unsigned int   id;
    char           name[SIZE];
} Entry;

After reading the data from file I have all the read values stored in the following field of my class:

QVector<Entry> entires;

I do expose this list to QML with the following declaration:

Q_PROPERTY(QVector<Entry> FileContents READ getEntries NOTIFY TmpFileUpdated)

followed by getter and setter methods.

inline QVector<Entry> getEntries () 
{ 
    return this->entires; 
}

inline void setEntries(QVector<entires> entries) 
{ 
    this->entires= entries; 
    emit TmpFileUpdated(); 
}

Each time the file is read “setEntries” method is used to set the vector and to emit the signal.

The listview in QML has the the Q_PROPERTY FileContents attached to the model:

ListView {
    id: myListView
    width: 200
    height: 400

    model: myInjectedObject.FileContents

    delegate: Row {
        spacing: 10         
        Text {
            text: model.entry_type // (1)
            font.pixelSize: 12
            horizontalAlignment: "AlignHCenter"
            verticalAlignment: "AlignVCenter"
            height: 20
        }
    }
}

How to access the data that is kept on the list of structures and display it in QML?

UPDATE:
After your suggestions I changed the code slightly and it compiles fine now. A following class was created:

class EntryClass: QObject
{
    Q_OBJECT
    Q_PROPERTY(QString entry_name READ getEntryName)
public:
    inline EntryClass(Entry entrystruct)
    {
        this->entry = entrystruct;
    }
private:
    Entry entry;

    inline QString getEntryName() const
    {
        return this->entry->entry_name;
    }    
};

ListView {
    id: myListView
    width: 200
    height: 400

    model: myInjectedObject.FileContents

    delegate: Row {
        spacing: 10       
        Text {
            text: modelData.entry_name // (1)
            font.pixelSize: 12
            horizontalAlignment: "AlignHCenter"
            verticalAlignment: "AlignVCenter"
            height: 20
        }
    }
}

UPDATE 2
OK, after some more analysis I’ve managed to find the solution that works. Regarding the ListView declaration above it was updated to the current state (passing struct by reference didn’t work, I had to use copy by value).

Both answers were helpful in some way, but since only one can be accepted I’ll accept the first one written by Radon.
Thank you both for guidance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:12:25+00:00Added an answer on May 26, 2026 at 3:12 pm

    QML cannot access “low-level” struct types.

    But you can create a class EntryClass that inherits QObject and add id and name as Qt properties (internally EntryClass can use the data of the corresponding Entry struct instances, e.g. by using a pointer to it). Then you should be able to access these properties in QML.

    (But I didn’t test it)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have an embedded resource in your VB6 project that contains a binary
In my project I have a schema file and utility that I wrote to
I have a .resx file which contains some string resources for my project. At
Informative I'm working on a project that loads a binary file from the disk.
I have a project which has a set of binary dependencies (assembly dlls for
I have project that uses Hibernate: hibernate-core-3.6.7.Final.jar In its POM I found: <dependency> <groupId>org.hibernate.javax.persistence</groupId>
I have a project that uses totoiseSVN. Before upgrading it to 1.7 version all
I have a project that I have been working on and am closing to
In my project I have a class which I Serialize in Binary format to
I am observing a different output from a C++ compiled binary file, that calls

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.