i mean should i use it in this way?
Code:
void myEditDialog::on_myFirstComboBox_currentIndexChanged(int index) { model.setData(model.index(0, 0), 7, Qt::EditRole); // sets 7 into default role of item (0, 0) }
Printable View
i mean should i use it in this way?
Code:
void myEditDialog::on_myFirstComboBox_currentIndexChanged(int index) { model.setData(model.index(0, 0), 7, Qt::EditRole); // sets 7 into default role of item (0, 0) }
So every time someone selects a different item from the combo box, you want to store the value 7 into item( 0, 0 )? Why?
Why don't you try to explain what you really want to do when someone changes the combo box selection?
in my diagram below i have a form with a lineedit a tableview a combobox..
in my database table i have 4 columns and many rows and this columns are: ID , Name , Filter Code , Other Data... and i am just working in tow columns.. Name and Filter Code columns..
and as i am showing in my diagram in column (Filter Code) there are alot of rows but they divided into groups and every group has a different number which is that (filter code ) the lineedit displays the filtered number.. for example if it is 22 the filter code column in tableview displays only the group with that number..
now the combobox displays column (Name) contains which is name1 , name2 , name3 , name4... i assume that the column (Name) in tableview displays name2 and the 22 group belongs to that name.. the combobox should display the same name which is name2 and if we change the contain in combobox the change should be applied to all the rows that belongs to the group that already filtered by the number 22 which displayd in lineedit..
this is already happened because i am using QDataWidgetMapper but the change apply only to the last row not to all rows which i want..
in my form i am using: QLineEdit QComboBox QTableView , QSqlRelationalTableModel , QSortFilterProxyModel , QDataWidgetMapper..
wolcome
I am sorry but I don't understand what you are trying to do.
Do you want to change the database? (That is, if the user types a new name into the combobox do you want "newName" to replace "name2" in the database)?
Do you want to select something new from the database (read only) when the user changes the combobox selection or enters a new code in the line edit?
hi!
for the lineedit i used it only to filter database.. so the table displays only filtered rows... the combo box i want to use it with filtered rows so if i change data in that combo box the data should be changed also in the filtered rows so if the names were name2 in the table and changed combobox to name3 the change should be aplied to all that filtered rows only (the filtered rows with linedit) after that i will call SubmitAll function with save button to update database... thats all thank you.
Added after 9 minutes:
yes i already have names in the database and it is a relationship database the combo box will update values because it is a forignkey.. and use qsqlrelationaltablemodel with itemdelegate.. thank you!