Results 1 to 3 of 3

Thread: Probably a simple question on sharing one model between two views

  1. #1
    Join Date
    Jun 2014
    Posts
    30
    Thanks
    4
    Qt products
    Qt5

    Default Probably a simple question on sharing one model between two views

    Hi all,

    I appreciate all the help you've given me in the past few days. I am doing more complex stuff with Qt now and I truly do appreciate the help you guys offer to guide me on the right direction.

    In this case, I am working with legacy code. I have a large deque data structure. This is the data source. I need two QTableView widgets on a single dialog that utilize the same data source but show different columns of data. Since each table displays different columns of data, how can they share the same QAbstractItemModel? Is this what proxy models are for?

    Thank you kindly,
    Joseph

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Probably a simple question on sharing one model between two views

    The views are free to hide columns independently of each other. See QTableView::setColumnHidden()
    You could use a proxy model to do this but generally programmers want the least possible work.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Probably a simple question on sharing one model between two views

    You can also use two models unless you need the views to share a model, e.g. because they also should share a selection model.

    Cheers,
    _

Similar Threads

  1. Model with two very different views
    By mholmes in forum Qt Programming
    Replies: 3
    Last Post: 7th April 2010, 23:19
  2. how to disable views from a model
    By zeeeend in forum Qt Programming
    Replies: 3
    Last Post: 9th September 2008, 21:14
  3. Question about a model with multiple views
    By awhite1159 in forum Qt Programming
    Replies: 3
    Last Post: 26th June 2008, 00:27
  4. 2 Views 1 Model
    By PrimeCP in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2007, 01:40
  5. Model Views and QLabel
    By naresh in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2006, 15:14

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.