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 5953535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:50:24+00:00 2026-05-22T17:50:24+00:00

I have a following problem. I’m trying to implement a model for my QTreeView

  • 0

I have a following problem.

I’m trying to implement a model for my QTreeView that would load dynamically data from sql table.

Table looks like this:

CREATE TABLE xcmObjects
(
   id                       INT               AUTO_INCREMENT PRIMARY KEY NOT NULL,
   id_parent                INT               DEFAULT 0 NOT NULL ,
   title                    TEXT

);

id_parent contains id of a parent record – so they form a structure.

I’d like my model to load data from this table only when needed. In other words I don’t want to load the full structure into memory, instead I wan’t to read children of only those nodes that have been opened by the user.

QSqlQueryModel and QSqlTableModel seem to work only for flat tables.

I think that one solution to this problem would be to implement custom QAbastractItemModel class and inside store seperate QSqlQueryModel instances for each open node (including the top level invisible parent). And then rewrite each method and forward requests to apropriate models.

Maybe there is some simpler solution ? 🙂

Thanks for help.

  • 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-22T17:50:24+00:00Added an answer on May 22, 2026 at 5:50 pm

    I don’t think it would be too difficult to work through a subclass of QAbstractItemModel to do this. Your top level would be all items in the table where parent_id is 0. Store the ID of each item as the internal data for the QModelIndex classes, and then you can use the parent index passed in to various functions to construct new queries for the data.

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

Sidebar

Related Questions

I have the following problem in my Data Structures and Problem Solving using Java
I have following problem: My webservice application returns xml data in following order: <my_claims>
i have following problem from book introduction algorithm second edition by MIT university problem
I have following problem. In my view model I defined some list properties as
I have the following problem. I have a list of different text lines that
I have following problem with site http://huti.ru . When trying to add any of
Hello I have following Problem: Within an uninstall-process I load a JAR (jdbc-driver). URL
I still have following problem EXPLAIN EXTENDED SELECT `item`.`id`, `item`.`timestamp`, `item`.`label` FROM item WHERE
I have following problem: My program should decide at runtime to load an function
I have following problem that in a transformation (which is completely done in memory)

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.