[Qt-interest] How to retreive a value in relational sql model?
jjDaNiMoTh
jjdanimoth at gmail.com
Wed Dec 2 18:40:30 CET 2009
2009/12/2 Yevgen Yashchenko <lester.dev at gmail.com>:
> Hi, I have a QSqlRelationalTableModel with a column used as a foreign key in
> another table.
> Let's say the tables are like this:
>
> Table1: id, name_id
> Table2: id, name
>
> so table1.name_id is mapped as QSqlRelation to table2.name with an index set
> to table2.id.
>
> What I need is to retrieve that name_id in the delegate attached to table1
> view to make some additional computations.
> In delegate I have 'index' so I can use it to get the value from the model,
> but the model->data() returns me a mapped value
> from the table2.name what I don't need at the moment. Is there any way to
> get that table1.name_id without a subclassing model
> without those jerky qhashes and maps?
>
> Thanks.
My approach is retrieve value from columnId ( which I know ) at the
row pointed out by the mapped value.
There are many ways to implement this, but I don't know if there are
better strategies.
--
Key Fingerprint
4588 F931 A6E7 C7D5 A302 3064 12EB E87F 9B28 A9D2
More information about the Qt-interest-old
mailing list