Results 1 to 4 of 4

Thread: model View programming problem

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question model View programming problem

    hi,
    i have a problem in a program that use model view.
    i have QTreeView object that display titles of a book, these titles are over than 5000
    title and they are stored in a SQLITE database.

    i tried two solution :
    1- i inhreted QAbstractItemModel but i get some problems becuase as i understanded from the documentation that i should store the data items in my own class.
    2- i tried to to use QStandardItemModel but i noteced that i should store the titles in a
    separated QList of of QStandardItem.

    now i want to use the database directly without any model becuase this takes alot of memory. and i want this job to be fast as possible because i may have titles more than 10,000 .
    i am thinking :
    can i use just QTreeWidget to access the database via a QSqlQuery class?
    if you have any other solutions please help me?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: model View programming problem

    Have you seen QSqlTableModel and QSqlQueryModel?

  3. #3
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: model View programming problem

    yes, i know these two classes .
    but as i know that they are not working with trees.
    note :
    i have a table in my database that has the following schem :
    +id (1, 2, 3,4, ...)
    |
    +title (title1, title1-1, title2, ....)
    |
    +lvl (1, 2,1,....)
    |
    +sub (0,0,0,...)
    i want to list the titles in the tree and put each title in it's appropriate level according to lvl field.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: model View programming problem

    They are not working with trees but you can apply a proxy on a flat model to make it hierarchical.

  5. The following user says thank you to wysota for this useful post:

    mismael85 (2nd April 2008)

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  2. tableview model view problem
    By skuda in forum Qt Programming
    Replies: 5
    Last Post: 3rd December 2007, 14:02
  3. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  4. Table Model / View Problem -- Data Not Displaying
    By jhendersen in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2007, 06:45
  5. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 13:01

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.