Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to insert item to combobox that uses a QSQLquery model
I have Combobox and SQLite. I read the database and load the data into the combobox. How can I add data to this combobox that does not exist in the database?
I want to add this item to the list of data in the combo but it does not work
No, that does not work. It is either/or. Either you use an editable model like the default model, or you use an SQL query model. An SQL query model is not editable, so you cannot add items to it. You might try if it works with an QSqlTableModel instead, but I doubt it. Instead, you could read-in the data from the query, and add this data as items in your combobox. That will allow you to add new items, that you can then add back to the database.
Thank you for your reply, but i dont know how to read the data from the modelquery
do you have an example?
I'd not use the query model in in this case, but use a [[doc:QSqlQuery]] directly. The documentation of QSqlQuery contains an example on how to read the results.
I don't want to use QSQLQuery. Is there a way to copy the model into another editable model?
Sure, but that would be more complicated to do, I think. Did you try using a QTableModel instead?
I found this link which describes it. Thank you Andre