Results 1 to 4 of 4

Thread: metadata in a QSqlQueryModel/QTableView?

  1. #1
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default metadata in a QSqlQueryModel/QTableView?

    I have a QSqlQueryModel tied to a QTableView with "select lastname, firstname, ID from Account", displaying non-unique lastname and firstname columns. I want to store a special ID field/metadata to each record (similar to widget item's data roles?), so that when the user double clicks on an entry, I can just extract the ID and process it using the special ID, without making an extra query to the database. But I don't want to display the ID column. How should I do this? Maybe there are multiple ways to do this?

    Thanks,
    Software Engineer



  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: metadata in a QSqlQueryModel/QTableView?

    use QTableWidget whitout sqltablemodel and save each cell to a qlist class name ....
    extedet QTableWidgetItem ....
    Have a look on code ..... http://www.qtforum.de/forum/viewtopic.php?t=2431 and you can browe limit next prev.....
    Last edited by jacek; 13th July 2006 at 11:50. Reason: post date has been changed to restore the order of messages in the thread

  3. The following user says thank you to patrik08 for this useful post:

    gfunk (13th July 2006)

  4. #3
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: metadata in a QSqlQueryModel/QTableView?

    Hmm, I was hoping to continue using a QTableView...
    I tried calling tableView->setColumnHidden() , maybe I'll use this for now...
    Software Engineer



  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: metadata in a QSqlQueryModel/QTableView?

    Quote Originally Posted by gfunk
    I tried calling tableView->setColumnHidden() ,
    Maybe you invoke it too early?

    Another solution is a proxy model (see QAbstractProxyModel).

  6. The following user says thank you to jacek for this useful post:

    gfunk (13th July 2006)

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.