[Qt-interest] How to get an ID for a description selected in a QComboBox?
Marcelo Magno T. Sales
mmtsales at gmail.com
Sun Jan 16 22:10:13 CET 2011
Hello,
In a form, I have a QTableView which uses a QSqlTableModel. This model
should be filtered to select only those rows where the ID field matches
a value selected by the user in a QComboBox in this form. However, the
ID is a FK to another table. In the QComboBox, which uses a model with
two columns (ID and description), the displayed values are the
descriptions from that other table. When the user selects a description
in the QComboBox, I must be able to get its ID to set the filter to the
QTableView's model. What's the best approach to achieve this? I couldn't
find a way to get the value of the ID for the selected description, nor
to get the model index for the selected value in the QComboBox.
Thanks,
Marcelo
More information about the Qt-interest-old
mailing list