Z
Z
Zakhar Alekseenko2015-10-26 08:26:36
SQL
Zakhar Alekseenko, 2015-10-26 08:26:36

SQLRelationTableModel foreign key to own PK?

Hello.
I use qt + sqlite. I created the Sensors table in it with a foreign key pointing to the same table (to the primary key). I need each Sensor instance to have information about another Sensor for temperature compensation. I create QSqlRelation for foreign key

int idSensorFK = m_sensors_model->fieldIndex("FK_Termocomp");
m_sensors_model->setRelation(idSensorFK, QSqlRelation("Sensors", "idSensor", "SensorName"));

I do select
I receive ambiguous column name for each field.
How can SQLRelationTableModel serve external keys on the table itself?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question