Answer the question
In order to leave comments, you need to log in
Question on QTableView, how to split rows into cells from one QlineEdit?
I can't figure out how to fill multiple lines that are passed from one lineEdit, for example, with a line separator (such as a semicolon or a space).
Now I have code like this for inserting a row:
QStandardItemModel *model = new QStandardItemModel();
QStandardItem *item;
for (auto x : tx->AddrsTo) {
for (int i = 0; i < tx->AddrsTo.size(); ++i) {
item = new QStandardItem(QString::fromStdString(x));
model->setItem(0, i, item);
}
}
this->findChild<QTableView*>("Adresses_tableView")->setModel(model);
Answer the question
In order to leave comments, you need to log in
use split
doc.qt.io/qt-5/qstring.html#split
QStandardItemModel *model = new QStandardItemModel();
for (auto& x : tx->AddrsTo)
{
Qstring s(x.c_str());
QStringList items = s.split(';');
int sz = items.size();
for(int i = 0; i < sz; ++i)
{
model->setItem(0, i, new QStandardItem(items[i]));
}
}
this->findChild<QTableView*>("Adresses_tableView")->setModel(model);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question