no bro i am sorry i don't know![]()
can you tell me how![]()
no bro i am sorry i don't know![]()
can you tell me how![]()
You use the QAbstractItemModel::setData() method. In general if you want to use models, you should read about them first.
jaafari (3rd April 2015)
and how to use QAbstractItemModel::setData() ?![]()
Easy:
- you stop being lazy;
- you go read the documentation as you were already advised to;
- you try to solve your problem;
- you come back and explain the approaches you tried, and ask specific questions.
Does that sound reasonable to you, or would you rather have other people do for free the work you are paid for?
jaafari (3rd April 2015)
any help guys or should i pay to someone to tell how?
jaafari (5th April 2015)
Last edited by jaafari; 5th April 2015 at 20:32.
I can give you an example for free.
Qt Code:
model.setData(model.index(0, 0), 7, Qt::EditRole); // sets 7 into default role of item (0, 0)To copy to clipboard, switch view to plain text mode
jaafari (9th July 2015)
and what about combobox:
Qt Code:
void myEditDialog::on_myFirstComboBox_currentIndexChanged(int index) { }To copy to clipboard, switch view to plain text mode
should i do it like this?
i mean should i use it in this way?
Qt 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) }To copy to clipboard, switch view to plain text mode
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?
jaafari (11th July 2015)
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?
jaafari (21st July 2015)
Call it on your model passing the index, value and role in the model you wish to change (e.g. Qt::EditRole).
jaafari (3rd April 2015)
Bookmarks