QApplication app(argc,argv); QWidget w; QString str1("Number: "),str2(" Sum: "); QStringList str; QListWidget s(&w); uint sum=0; w.show(); for(int i=0;i<150000;++i) { sum+=i; str << (str1+QString::number(i)+str2+QString::number(sum)); } s.addItems(str); app.exec();
Diff-str << (str1+QString::number(i)+str2+QString::number(sum));+str << QString("Number: %1, Sum: %2").arg(i).arg(sum);
QListWidget *lw; lw=new QListWidget(); lw->setUniformItemSizes(true);QString str1("Number: "),str2(" Sum: "); QStringList str; uint sum=0; for(int i=0;i<=150000;++i) { sum+=i; str << ((str1+QString::number(i)+str2+QString::number(sum))); } lw->addItems(str);
QVector<QString> vector(150000); uint sum=0; for(int i=0;i<150000;++i) { sum+=i; vector[i]= QString("Number: %1 Sum: %2").arg(i).arg(sum);; } QStringList str(QList<QString>::fromVector(vector)); lw->addItems(str);
uint sum=0; for(int i=0;i<=150000;++i) { sum+=i; str.append(QString("Number: %1 Sum: %2").arg(i).arg(sum)); } model->setStringList(str); lv->setModel(model);
QStringList str; uint sum=0; char x[100]; for(int i=0;i<=150000;++i) { sum+=i; sprintf(x,"Number: %i Sum: %i",i,sum); str.append(x); } model->setStringList(str); lv->setModel(model);