Results 1 to 4 of 4

Thread: Display QStandardItem Properties in a QTableView row

  1. #1
    Join Date
    Jan 2011
    Posts
    70
    Thanks
    43
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Display QStandardItem Properties in a QTableView row

    I have a custom object based on QStandardItem that possesses several properties. Normally these objects are listed in a QTreeView, but occasionally I'd like to display a report with them in a QTableView.

    Let's say, for example, that Person derives from QStandardItem and has the properties Name, Address, FavoriteColor, and SpouseName. The Person's DisplayRole is usually Name, but for the QTableView I'd like to have an entire row populated by their Name, Address, FavoriteColor, and SpouseName, each in a column.

    Is there a straightforward Qt way to display a single QStandardItem across several rows like this? All I can think of is spawning a row of generic QStandardItems, each with its text set to the property I want, but that seems... rough, at best.

    Or... is my concept fundamentally flawed at the outset when I had Person inherit from QStandardItem?

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Display QStandardItem Properties in a QTableView row

    Maybe try another way around, create a delegate for the QTableView and display appropriate text for particular cell.
    That way if in the feature You decide to use QListView then simply create another delegate and use already existing data structure without changing a thing with it.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  3. #3
    Join Date
    Jan 2011
    Posts
    70
    Thanks
    43
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Display QStandardItem Properties in a QTableView row

    Yes, delegates communicate the idea that I'm trying to accomplish. My thought is that I would assign a QStandardItem derivative to every row, and then assign a delegate to each column to display a certain ItemDataRole of that QStandardItem.

    Doesn't QTableView work on the premise that QStandardItems are assigned to cells, not rows, though? That's my point of confusion.

  4. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Display QStandardItem Properties in a QTableView row

    Yes they are per cell not the row.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. Replies: 0
    Last Post: 18th April 2011, 02:21
  2. Can I display/print properties of QWidget?
    By dpatel in forum Qt Programming
    Replies: 5
    Last Post: 25th November 2010, 13:57
  3. Replies: 10
    Last Post: 20th June 2010, 22:29
  4. Display File Properties [Solved]
    By DrDonut in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2009, 12:45
  5. Replies: 5
    Last Post: 16th May 2006, 20: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.