archqt
9th January 2011, 14:46
Hi,
here is the problem. I have 2 tables Person and Status, 2 views and a foreign key in Person to Status.
If i add new status in Status Table and after i go to Person, with the QSqlrelationalDelegate i can choose the status i want.
But if after i go back to Status view and add a new line Status, then i do :
if (m_model->relationModel(m_foreign)) m_model->relationModel(m_foreign)->select();
To update the delegate, so i can see the new value in the combobox, but...when i click on it. The new line is added on Person Table BUT WITH EMPTY FOREIGN KEY but i see nothing on the View. So i suppose the combobox used in delegate doesn't send the good id but why ? I tried lot of things. I can add other person only if the status were added first in Person Status. If the status is once added after i added first person then it doesn't work.
As there is no example that use 2 views and foreign key like this i don't know if it is possible doing it that way.
If i restart program i can add person but last status as it is already in Status Table before i add first Person.
Thanks for answer
here is the problem. I have 2 tables Person and Status, 2 views and a foreign key in Person to Status.
If i add new status in Status Table and after i go to Person, with the QSqlrelationalDelegate i can choose the status i want.
But if after i go back to Status view and add a new line Status, then i do :
if (m_model->relationModel(m_foreign)) m_model->relationModel(m_foreign)->select();
To update the delegate, so i can see the new value in the combobox, but...when i click on it. The new line is added on Person Table BUT WITH EMPTY FOREIGN KEY but i see nothing on the View. So i suppose the combobox used in delegate doesn't send the good id but why ? I tried lot of things. I can add other person only if the status were added first in Person Status. If the status is once added after i added first person then it doesn't work.
As there is no example that use 2 views and foreign key like this i don't know if it is possible doing it that way.
If i restart program i can add person but last status as it is already in Status Table before i add first Person.
Thanks for answer