Results 1 to 5 of 5

Thread: setRelation and NULL in ID

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: setRelation and NULL in ID

    The problem is that Qt uses inner join and you want to use outer join, so instead you can use QSqlTableModel (if you have a view) or QSqlQueryModel. In the latter case the model won't be editable and with view it depends on the underlying DBMS.

  2. #2
    Join Date
    Aug 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setRelation and NULL in ID

    I am also interested in this problem. But I dont understand the answer from jacek. Have someone solved this problem? Thanks.

  3. #3
    Join Date
    Jul 2008
    Location
    Spain
    Posts
    23
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setRelation and NULL in ID

    By now, I will use a record with identifier 0 and empty description in my tables.

    See this too:
    http://www.qtcentre.org/forum/f-qt-p...del-12784.html
    Auryn
    Starting to learn the world of Qt

  4. #4
    Join Date
    Oct 2014
    Posts
    22
    Qt products
    Qt3 Qt4 Qt5 PyQt3 PyQt4

    Default Re: setRelation and NULL in ID

    Hi,

    I know this is an old thread, but you need to set the setJoinMode. By default the sqlRelationalTableModel uses an inner join. You need to set it to be a left join.
    self.setJoinMode(QtSql.QSqlRelationalTableModel.Le ftJoin). This took me forever to figure out because the row would go into the database just not the view.

    http://pyqt.sourceforge.net/Docs/PyQ...ml#setJoinMode

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
  •  
Qt is a trademark of The Qt Company.