Results 1 to 3 of 3

Thread: Model/View ...Discrimination

  1. #1
    Join Date
    Feb 2007
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Model/View ...Discrimination

    My goal is to have several views connected to a single model. But, the catch is that I want to be able to dictate when a particular view is affected by changes in the model.

    For example, lets say I'm using a QTreeView for a file directory hierarchy and a QTableView for the contents of the file itself. Using a single QAbstractItemModel, which is only populated on demand, how would I achieve this?

    I tried: viewObject->disconnect(modelObject), which did not work as I expected.


    Any suggestions appreciated,
    -travlr

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Model/View ...Discrimination

    See if overriding void QAbstractItemView::dataChanged helps you.
    You should set a flag in your view that tells you if updates are allowed or not.
    If tey are not then do nothing in your reimplementation of dataChanged.
    Otherwise call the base class version.

    Regards

  3. #3
    Join Date
    Feb 2007
    Posts
    24
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Model/View ...Discrimination

    Thank you for your response, Marcel.

    I also realized that any initial populating (through the model's constructor) defeats this need, so I'll simply populate all branches of the model lazily to control the views better. -travlr
    Last edited by travlr; 12th August 2007 at 15:39.

Similar Threads

  1. Drag & drop with model/view (Qt4)
    By yogeshm02 in forum Qt Programming
    Replies: 16
    Last Post: 19th September 2011, 20:36
  2. Using QGraphicsView with model/view programming
    By JLP in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2007, 11:04
  3. MODEL/VIEW programming and TABLES
    By newbie in forum Qt Programming
    Replies: 5
    Last Post: 27th August 2006, 21:26
  4. MODEL/VIEW programming
    By mira in forum Newbie
    Replies: 3
    Last Post: 21st April 2006, 11:19
  5. [QT4.1.1 XP] multi-columns list model/view
    By incapacitant in forum Newbie
    Replies: 1
    Last Post: 26th February 2006, 13:38

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.