Results 1 to 12 of 12

Thread: Setting QSqlTableModel from c++ to .qml tableView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Setting QSqlTableModel from c++ to .qml tableView

    QAbstractItemModel::roleNames() allows you to map custom roles name to custom role values.

    So you specifiy some integer role values for the data you want to get (usually usign an enum) and then map these values to the strings that you want to use on the QML side.

    Cheers,
    _

  2. #2
    Join Date
    Jan 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Setting QSqlTableModel from c++ to .qml tableView

    Hi, I'm only able to display the first column with the Display Role, Can I only use that role? If so, how do I get the other columns to show?

  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: Setting QSqlTableModel from c++ to .qml tableView

    Quote Originally Posted by heczaco View Post
    Hi, I'm only able to display the first column with the Display Role
    Unsurprisingly, since that is one of the standard roles that is also in the standard role name mapping.

    Quote Originally Posted by heczaco View Post
    Can I only use that role?
    Of course not, that would make models pretty useless.

    Quote Originally Posted by heczaco View Post
    If so, how do I get the other columns to show?
    See comment #10.

    Cheers,
    _

Similar Threads

  1. Default sort in QSqlTableModel and tableview
    By rdjenner in forum Qt Programming
    Replies: 0
    Last Post: 17th August 2011, 17:15
  2. Replies: 7
    Last Post: 30th June 2011, 10:16
  3. Replies: 0
    Last Post: 17th June 2011, 09:11
  4. QSqlTableModel Setting Current Row?
    By fifth in forum Qt Programming
    Replies: 4
    Last Post: 15th June 2008, 13:44
  5. setting UserRole data in QSqlTableModel
    By orgads in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2008, 09:40

Tags for this Thread

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.