apply change to filtered rows is it possible?
hi there!
i am using QSqlRelationalTableModel QSqlTableModel QDataWidgetMapper QSortFilterProxyModel QTableView..
to filter multiple rows in a column and i use QLineedit to display code of that filtered rows and after filtering i want to change other rows in my second table & my thrid table using tow QComboBox so if i changed content in one of that Combobox it should apply the change to all the rows that have the same code in column( N° 3) whech displaied in QLineEdit.. how to do that is it possible? i am sorry if i can't explain well due to my bad english thanks for help :o
Code:
{
ui->setupUi(this);
//bla bla bla...
//bla bla bla...
myeditModel->setTable("myFirstTable");
myeditModel
->setRelation
(myeditModel
->fieldIndex
("myFirstForeignKeyID"/*1*/),
QSqlRelation("mySecondTable",
"id",
"name"));
myeditModel
->setRelation
(myeditModel
->fieldIndex
("mySecondForeignKeyID"/*2*/),
QSqlRelation("myThirdTable",
"id",
"name"));
myeditModel
->setRelation
(myeditModel
->fieldIndex
("myCodeID"/*3*/),
QSqlRelation("myFourthTable",
"id",
"myCode"));
myeditModel->select();
ui->myFirstComboBox->setModel(relationModel1);
ui->myFirstComboBox->setModelColumn(relationModel1->fieldIndex("name"));
ui->mySecondComboBox->setModel(relationModel2);
ui->mySecondComboBox->setModelColumn(relationModel2->fieldIndex("name"));
mapper->setModel(myeditModel);
mapper->addMapping(ui->myFirstComboBox, 1);
mapper->addMapping(ui->mySecondComboBox, 2);
mapper->addMapping(ui->codeEdit, 3);
mapper->addMapping(ui->dateEdit, 4);
//bla bla bla...
//bla bla bla...
mapper->setCurrentIndex(row);
QString filterValue
= ui
->codeEdit
->text
();
myproxy->setSourceModel(myeditModel);
myproxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
myproxy
->setFilterRegExp
(QRegExp(filterValue, Qt
::CaseInsensitive,
QRegExp::FixedString));
myproxy->setFilterKeyColumn(/*-1*/3);
ui->EditView->setModel(myproxy);
ui->EditView->resizeRowsToContents();
ui->EditView->resizeColumnsToContents();
ui->EditView->setSortingEnabled(true);
ui->EditView->setColumnHidden(0, true);
}
myEditDialog::~myEditDialog()
{
delete ui;
}
void myEditDialog
::on_codeEdit_selictionChanged(const QString &arg1
) {
myproxy->setFilterFixedString(arg1);
}
Re: apply change to filtered rows is it possible?
I don't see a problem. What have you done so far? How are you updating those two other tables?
1 Attachment(s)
Re: apply change to filtered rows is it possible?
thank you !
thank you !
i am sorry for my misstakes bro.. :rolleyes: i don't update the tow other tables it is a relationshape and i want to update only numbers in rows of column 1 ("myFirstForeignKeyID"/*1*/) and column 2 ("mySecondForeignKeyID"/*2*/) whech is filtered by column 3 ("myCodeID"/*3*/) inside ("myFirstTable") whech i am displaing in my tableview.
let say LineEdit displaies number (90) and there are 4 rows with the same (90) in column 3 whech are already filtered and column 1 for example displaies 4 rows whech are Foreign Keys and these foreign keys all of theme are number (1) and they displaies the same "name" (name1,name1,name1,name1) also ComboBox1 displaies the same "name" whech is (name1)... now i want to change ComboBox1 to (name9) and this changing should be applied automaticly to those 4 rows so the foreign keys were (1,1,1,1) now should be (9,9,9,9) please look at my diagram and let me now what should i do... :rolleyes:
Re: apply change to filtered rows is it possible?
Ok but what is the problem you are having to implement what you wrote here?
Re: apply change to filtered rows is it possible?
no problem bro :o
i just need some help on how combobox apply change to those filtered rows maybe i should write something like this:
Code:
void EditDlvrDialog::on_myFirstComboBox_somethingChanged(something)
{
something
something
}
:cool:
Re: apply change to filtered rows is it possible?
Well, you take the value from the combobox and using that value you update your model. Do you know how to update values from your model?
Re: apply change to filtered rows is it possible?
no bro i am sorry i don't know :(
can you tell me how :confused:
Re: apply change to filtered rows is it possible?
You use the QAbstractItemModel::setData() method. In general if you want to use models, you should read about them first.
Re: apply change to filtered rows is it possible?
and how to use QAbstractItemModel::setData() ? :)
Re: apply change to filtered rows is it possible?
Quote:
Originally Posted by
jaafari
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?
Re: apply change to filtered rows is it possible?
Call it on your model passing the index, value and role in the model you wish to change (e.g. Qt::EditRole).
Re: apply change to filtered rows is it possible?
Quote:
Originally Posted by
yeye_olive
Does that sound reasonable to you, or would you rather have other people do for free the work you are paid for?
i am not a programmer bro.. i am just here to learn and in fact there is no documentation in my language :( thank you :)
Re: apply change to filtered rows is it possible?
Quote:
Originally Posted by
jaafari
i am not a programmer bro.. i am just here to learn and in fact there is no documentation in my language :( thank you :)
There is documentation in English. This forum is English. If you can't understand English documentation, how are you going to understand my English explanation?
Re: apply change to filtered rows is it possible?
Quote:
Originally Posted by
wysota
There is documentation in English. This forum is English. If you can't understand English documentation, how are you going to understand my English explanation?
it is very difficult for me and in some conversation i try translator (thanks to google).. i hope one day other people can find Qt in other languages
Re: apply change to filtered rows is it possible?
any help guys or should i pay to someone to tell how?
Re: apply change to filtered rows is it possible?
Quote:
Originally Posted by
jaafari
any help guys or should i pay to someone to tell how?
What's wrong with the solution already given in comment #11?
Cheers,
_
Re: apply change to filtered rows is it possible?
my dear i just want an example even if i will pay for it no problem :cool:
Added after 5 minutes:
Quote:
Originally Posted by
yeye_olive
Easy:
Does that sound reasonable to you, or would you rather have other people do for free the work you are paid for?
give me a example pravite and i am ready to pay for it.. just tell me how much that will cust?
Re: apply change to filtered rows is it possible?
I can give you an example for free.
Code:
model.setData(model.index(0, 0), 7, Qt::EditRole); // sets 7 into default role of item (0, 0)
Re: apply change to filtered rows is it possible?
and what about combobox:
Code:
void myEditDialog::on_myFirstComboBox_currentIndexChanged(int index)
{
}
should i do it like this?
Re: apply change to filtered rows is it possible?