How to print a vector in plain text in QT -


 int b=0;      qvector<int> z(5);      for(int i=0;i<5;i++)      z.push_back(i);      for(int i=0;i<z.size();i++)      {          b=z.at(i);          qstring str=qstring::number(b);               ui->mbox->settext(str);       } 

i wrote code print vector in plain text print first row want print whole vector not:mbox plain textedit

now there problem

qvector<int> z(5);      for(int i=0;i<5;i++)      z.push_back(i);          qstring str;          (int = 0; < z.size(); ++i)          {              if (i > 0)                  str += " ";              str += qstring::number(z[i]);          }           ui->mbox->settext(str);  }   

in first loop when wrote z.size() qt has caught exception thrown event handler. throwing exceptions event handler not supported in qt. must reimplement qapplication::notify() , catch exceptions there.

and in second when wrote z.size 10 output size of z 5 can see .what wrog first 5 output 0 , rest normal 0 1 2 3 4 should have 5 output wrong

you overwriting text every item in vector. construct qstring values this:

qstring str; (int = 0; < z.size(); ++i) {     if (i > 0)         str += " ";     str += qstring::number(z[i]); }  ui->mbox->settext(str); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -