Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.6.0
-
None
Description
Regarding main.cpp Example File "tutorials/widgets/nestedlayouts/main.cpp" [1]: the code filling the table model is pretentious and wasteful.
Currently:
QList<QStringList> rows = QList<QStringList>()
<< (QStringList() << "Verne Nilsen" << "123")
<< (QStringList() << "Carlos Tang" << "77")
<< (QStringList() << "Bronwyn Hawcroft" << "119")
<< (QStringList() << "Alessandro Hanssen" << "32")
<< (QStringList() << "Andrew John Bakken" << "54")
<< (QStringList() << "Vanessa Weatherley" << "85")
<< (QStringList() << "Rebecca Dickens" << "17")
<< (QStringList() << "David Bradley" << "42")
<< (QStringList() << "Knut Walters" << "25")
<< (QStringList() << "Andrea Jones" << "34");
foreach (QStringList row, rows)
{ QList<QStandardItem *> items; foreach (QString text, row) items.append(new QStandardItem(text)); model.appendRow(items); }My approach:
enum local_settings
{ NAME_LEN = 040, ROOM_LEN = 04 };
static struct userdata
const sc_userdata [] =
{{ "Verne Nilsen", "123" },
,
,
,
,
,
,
,
,
{ "Andrea Jones" , "34" }};
for
(struct userdata const *row (sc_userdata);
row < (&sc_userdata) [01]; ++row) {
char const *const l_data [] =
;
QList<QStandardItem *> items;
for
(char const (*const *an_attr) (l_data);
an_attr < (&l_data) [01]; ++an_attr)
items.append(new QStandardItem(*an_attr));
model.appendRow(items);
}
___
[1] <URL:http://doc.trolltech.com/4.6/tutorials-widgets-nestedlayouts-main-cpp.html>