Results 1 to 2 of 2

Thread: setting UserRole data in QSqlTableModel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default setting UserRole data in QSqlTableModel

    Hello,

    I'd like to set additional data for a table I acquire from an SQL server.

    Looking at the code of QSqlTableModel::setData(), it looks like it just ignores any role other than EditRole (it passes it to QSqlQueryModel, down to QAbstractItemModel, which does nothing).

    Is there any other way to set data for individual cells in the model?

    Thanks.

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

    Default Re: setting UserRole data in QSqlTableModel

    You can subclass the model and implement it yourself or use some kind of proxy model that would hold the additional data. SQL models only operate on the "displayable" data.

Similar Threads

  1. QSqlTableModel Setting Current Row?
    By fifth in forum Qt Programming
    Replies: 4
    Last Post: 15th June 2008, 13:44
  2. setting data of buffer to QTreeWidget column
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 17:12
  3. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53

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.