Results 1 to 5 of 5

Thread: QProxyModel + QQueryModel -> QTreeView

  1. #1
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QProxyModel + QQueryModel -> QTreeView

    Hi.

    I want to use the data from a QSqlQueryModel into a QTreeView. But modeling the data into a tree with QProxyModel.

    The SQL (create table) code is:
    Qt Code:
    1. CREATE TABLE categories(
    2. id INTEGER PRIMARY KEY,
    3. parent INTEGER,
    4. image VARCHAR(128),
    5. name VARCHAR(32)
    6. )
    To copy to clipboard, switch view to plain text mode 

    parent has the id of the parent

    Thanks

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

    Default Re: QProxyModel + QQueryModel -> QTreeView

    Is there a question here somewhere?

  3. #3
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProxyModel + QQueryModel -> QTreeView

    Quote Originally Posted by wysota View Post
    Is there a question here somewhere?
    Mmmm sorry....

    How can I implement the QProxyModel inherit class?

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

    Default Re: QProxyModel + QQueryModel -> QTreeView

    Don't use QProxyModel, but QAbstractProxyModel. Subclass it and reimplement all the pure virtual methods.

    Personally I would do it another way. I would implement a subclass of QAbstractItemModel (or QStandardItemModel) and connect appropriate signals to modify the model you want to expose in case the "source" model changes. Of course you can so the same with a proxy model, but then you wouldn't cache all the source items in the exposed model and I believe this is the simplest way to achieve your goal (unless your source model is really big, then it doesn't make much sense to cache items).

  5. #5
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProxyModel + QQueryModel -> QTreeView

    For the moment I have done a subclass of QStandardItem that internally execs a query in a update method.

    But the idea was have a QSqlQueryModel with a "complex" result and model it in distinct types of ways.

    Thanks anyway.

Similar Threads

  1. QTreeView repaint
    By graeme in forum Qt Programming
    Replies: 17
    Last Post: 13th March 2012, 13:27
  2. using QTreeView with a Database model
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 17th January 2007, 23:29
  3. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  4. Modify model data in QTreeView
    By YuriyRusinov in forum Qt Programming
    Replies: 6
    Last Post: 26th October 2006, 17:28
  5. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24

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
  •  
Qt is a trademark of The Qt Company.