QSqlRelationalTableModel and QItemDelegate
-
Hello,
I have a column which is the ID of my users this column id is replace by name using relationaltable. When I edit that cell I want to type a name instead of ID after typing each letter new related item will be shown and their ID after clicking on proper item the name and ID painted in one cell.
Any suggestion to implement above...
-
Hi,
-
@alex20 said in QSqlRelationalTableModel and QItemDelegate:
Is it possible to send other columns data or other variables to QSqlRelationalDelegate?
What do you mean by that ?
-
@alex20
The tableQSqlRelationalDelegate
acts on is the one of the associatedQSqlRelationalTableModel
(via the view). You could access the table name via that, if you needed it.The list it shows is obtained via a foreign key:
Unlike the default delegate,
QSqlRelationalDelegate
provides a combobox for fields that are foreign keys into other tables. To use the class, simply callQAbstractItemView::setItemDelegate()
on the view with an instance ofQSqlRelationalDelegate
:If you want to supply your own list, you wouldn't bother with a
QSqlRelationalDelegate
. -
Do you mean something like a QCompleter ?
-
Feed the completer with the database content.