@CEO said in How to display QTableWidget selected row in a qLineEdit of the same class?:
@JonB now I discovered you are either hoarding knowledge or might not have done any work on the question.
Yes, you're right. I have nothing better to do than lie to questioners about what I know and they should do, and I don't spend enough of my time writing the code demanded to save them time.
Here is an extract from my usage of the QDataWidgetMapper which I know nothing about from a sample project of mine. I'm sorry if my variables/widgets/model are not the same as yours. Also here I happen to be binding to QSpinBoxes, let me know if I need to change it to QLineEdits for you.
void SectorRegisters::initDataWidgetMapper()
{
// set up the `QDataWidgetMapper`
this->dwm = new QDataWidgetMapper(this);
// set model (this->sectorsModel is the model being used, in my case it's a `QStandardItemModel`)
SectorsModel *sectorsModel = this->sectorsModel;
dwm->setModel(sectorsModel);
// Vertical => widget mapped to row
dwm->setOrientation(Qt::Vertical);
// current index is always column #0
dwm->setCurrentIndex(0);
// Region mappings
dwm->addMapping(ui->spinRegionSocialState, SectorsModel::RegionSocialState);
dwm->addMapping(ui->spinRegionGoodAreas, SectorsModel::RegionGoodAreas);
dwm->addMapping(ui->spinRegionPoorAreas, SectorsModel::RegionPoorAreas);
dwm->addMapping(ui->spinRegionCash, SectorsModel::RegionCash);
// Here there are many further widget<->model-column mappings
// ...
}
You're welcome.