Important: Please read the Qt Code of Conduct -

QSqlRelationalTableModel - problem with non-existent rows

  • Hello.

    I have very big problem with my database application. If the main table contains foreign key which is set to NULL, the entire row is not displayed.

    My solution to the problem was to create a row in the relation's table called "None". When the user doesn't selects the link to relation's table (foreign key is not set) value is automaticlly set to default "NONE". Thanks to this the main table displays all available rows.

    For example: I have 3 tables:

    The place where the machine is set to "NONE"
    The place where the people is set to "NONE"

    The problem is in displaying a database VIEW which contains this 3 tables (also another): people, place and machine, becouse it looks like people have relations with machine. But it's not true. It looks like this becouse of the same place.

    Is possible to sublass QSqlRelationalTableModel for displaying rows of main_table which contains foreign key set to NULL???