QtSql Dataaware cells/boxes
I find the examples very helpful from Qt regarding Sql possibilities given by Qt. Thanks on this place.
Here is one of this examples:
When I click inside a box of the row "Genre" or "Author Name" than a dropdown appears like you can see on the picture, - highlighted with red frame.
This functionality is only given because it is used QSqlRelationalTableModel and with the function "setRelation" a relation is set to this columns "Genre" and "Author Name".
Is there a comfortable possibility given to do the same stuff only without QSqlRelationalTableModel?
Means there is a table like this
Only such table without any relations to other tables. And it should not be the aim to create related tables.
Now when I decide to change from ProcessMGA the Atribute "HasToDoWith" I would like to get the dropdown list where I can EITHER select from already existing values inside the attribute "HasToDoWith" OR just write a new one like "Banana".
I found newly this possibility
But well that is a ComboBox and not something inside the TableView.
But here I also need to find out how to say which attribute of the QSqlTblModel shall be taken inside the dropdown list of the combobox.
- need to find out how to say which attribute of the QSqlTblModel shall be taken inside the dropdown
Sounds to me you are looking for
(to select what column that is used in combobox)
My code looks like this
TblModel = new QSqlTableModel(this); TblModel->setTable("Tbl1"); TblModel->select(); ui->QComboBox1->setModelColumn(TblModel->fieldIndex("Attribute1"));
So the result is, although Attribute1 is filled with data, that the data will not appear in the dropdown of QComboBox.
No errors no warnings when compiling.
Are you sure fieldIndex and setModelColumn have the same idea about column numbering ?
Check the values.
Hey I got it !!! I am gutting better :) unbelivable I solved it this way:
And it works.
Still have the issue that I would like to have dropdowns inside of the QTableView, - the topic at the top.