Results 1 to 3 of 3

Thread: Get data from a QSqlRelationTableModel

  1. #1
    Join Date
    Jan 2013
    Posts
    43
    Thanks
    27
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Get data from a QSqlRelationTableModel

    Hello,
    I have the table Items(id, idColor, other, ...)
    To access this table i have :
    • model - QSqlRelationTableModel
    • view - QTableView


    To get data from the current index i use:
    Qt Code:
    1. qDebug() << model->data(indexField).toString();
    To copy to clipboard, switch view to plain text mode 

    This works fine, except for the field that are foreign keys (idColor), and that i used a QSqlRelationalDelegate. In this cases, instead of the id e get the related data (the color as a string), in the other table.
    How can i get the data form the table (the id) and not the related data?

    Thanks

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

    Default Re: Get data from a QSqlRelationTableModel

    Did you try using Qt::EditRole?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    aguleo (29th May 2014)

  4. #3
    Join Date
    Jan 2013
    Posts
    43
    Thanks
    27
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get data from a QSqlRelationTableModel

    Just tried all display roles: 0,1,2,3,4,5,13.
    None gives the result i want.

Similar Threads

  1. Replies: 0
    Last Post: 25th February 2014, 16:17
  2. Replies: 1
    Last Post: 26th November 2013, 20:25
  3. Replies: 4
    Last Post: 17th June 2009, 22:59
  4. Replies: 5
    Last Post: 8th October 2008, 20:01
  5. QSqlTableModel or QSqlRelationTableModel
    By munna in forum Newbie
    Replies: 3
    Last Post: 13th March 2006, 15:11

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.