c++ - Trying to display the list in QListView? -


can't list display?

enter image description here

/*create qlistview */ m_listviewa = new qlistview(this); m_listviewa->setgeometry(qrect(qpoint(0,100), qsize(100, 150)));  modela = new qstandarditemmodel( nrow, 1, );  //fill model value for( int r=0; r<nrow; r++ ) {     qstring sstr = "[ " + qstring::number(r) + " ]";     qstandarditem *item = new qstandarditem(qstring("idx ") + sstr);     modela->setitem(r, 0, item); } //set model m_listviewa->setmodel(modela); m_listviewa->setselectionmode( qabstractitemview::extendedselection ); 

qstringlist slist; foreach(const qstandarditem index, modela) //error {     slist.append( index.data(qt::displayrole ).tostring()); } 

this works... rather use "foreach"...

qstring stra; for(int r=0; r < modela->rowcount(); r++) {     stra += "\r\n" + modela->item(r,0)->text(); } qmessagebox *msgbox = new qmessagebox(0); msgbox->setgeometry(qrect(qpoint(200,200),qsize(400,400))); msgbox->setinformativetext(stra); msgbox->exec(); 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -