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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -