c++ - Qt - QStringList to QListWidget*item -
i have list of inputs csv document in qlistwidget, , want associate each item id, when double click specific item can configure it. tried "qlistwidgetitem *item = rowdata;", gave me error. code in constructor:
if (getin.open(qfile::readonly)) { //collect data file items = getin.readall(); //split data line line rowofdata = items.split("\n"); //close csv document getin.close(); } //go through data collected, , split them 2 delimiters. (int x = 0; x < rowofdata.size(); x++) { rowdata = rowofdata.at(x).split(",").first().split(":"); if(!rowdata.isempty()) ui->itemlistwidget->additem(rowdata.first()); qlistwidgetitem *item = rowdata; }
the function when item double-clicked:
void storage::on_itemlistwidget_itemdoubleclicked(qlistwidgetitem *item) { itemwindow = new itemwindow(this); itemwindow->show(); }
let me try answer. ofc error :
qlistwidgetitem *item = rowdata;
because rowdata stringlist not *qlistwidgetitem.
if want full row data rowofdata. can use following slot :
void storage::on_itemlistwidget_itemdoubleclicked(qlistwidgetitem *item) { qstring yourrowdata = rowofdata.at(ui->itemlistwidget->row(item)); itemwindow = new itemwindow(this); itemwindow->show(); }
Comments
Post a Comment