[SOLVED]QLineEdit With Model
-
Hm, can you elaborate what you mean by bind QLIneEdit (one value) to model (a lot of values)?
-
Yes the IDEA is just as POC (Proof of concept)
QTableView and QLineEdit in the MainWindow
There is a model that is derived from QAbstractTableModel, where I have a custom model that will be the data source (in .NET terminology) for the QTableView
When I click on one row, there should appear a specific column value in the LineEdit (lets say the first one which represent the first name),by changing the row the value should change to reflect the current row.When changing the value of LineEdit it should also instantaneously be changed in the QTableView because they have the same source.
This was easy to do with C# by setting the datasource field name (I miss those days)Regards
-
Thanks Andre, it's really what I was looking for I've did the following and it worked
@ ui->setupUi(this);
mymodel=new MyModel();
ui->tableView->setModel(mymodel);
mapper=new QDataWidgetMapper();
mapper->setModel(mymodel);
mapper->addMapping(ui->lineEdit,0);
mapper->toFirst();
@There are problem I'll try to figure out, when changing the selection on QTableView the LineEdit is not updated.
When changing the text in the lineEdit the text in the view doesn't change unless I leave the cell.Regards