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

  • SEARCH
  • Home
  • 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 8795067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:20:14+00:00 2026-06-13T23:20:14+00:00

I’m experimenting with Qt and the Model/View framework. I have some data that I

  • 0

I’m experimenting with Qt and the Model/View framework.
I have some data that I would like to display and edit in a tree view.
I have read the documentation and this tutorial, but I’m still unsure about what is the best practice in my case.
The data comes from a server and looks something like this:

int id;
int parentId;
QString name;
float price;

The id’s are “running” numbers and all unique so the data might look like this.

Id =1
parentId =0 
name= food

id = 5 
parentId =1
name = pizza

The id is of no interest to the end user and should not be displayed.

Getting this in to a hierarchy should be pretty straight forward using a recursive function. (But any ideas here are also most welcome)

  1. Should I put the data I get from the server straight in to a QStandardItemModel?
  2. Is there any point in creating my own class and inherit QStandardItemModel/Item?
  3. Would each field (id, name, price) be it’s own QStandardItem?

If yes on #3, When I edit the item that contains a name, how do I get the id connected to that name so I can post the change back to the server.

As you understand these are basics, a sketch of a recommended structure would be great.

  • 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-06-13T23:20:14+00:00Added an answer on June 13, 2026 at 11:20 pm

    Don’t use QStandardItemModel. If you’ve got an id, then store it the internalId of the QModelIndex and use QAbstractItemModel.

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

Sidebar

Related Questions

I'm trying to create an MVC view that will display some data in a
I am experimenting with Dart. I have created an on click event like so:
In my cakephp app I have an Option model. In my option/index view I
I understand that the proper structure for separation-of-concerns in MVC is to have view-models
I'm currently experimenting with the Yii framework and have come across a slight snag.
We have a data grid on a window that is bound to a collection
While experimenting with pixel shaders in WPF I decided to draw some pixels onto
When experimenting with (embedded) Apache Derby DB, I noticed that a fresh database, with
I'm experimenting with validating forms in the asp.net MVC framework. I'm focusing on server
Bit of an abstract problem here. I'm experimenting with the Domain Model pattern, and

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.