Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-13250

No-nonsense replacement for nestedlayouts

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • P3: Somewhat important
    • 4.7.1
    • 4.6.0
    • Documentation
    • 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

      { char name [NAME_LEN], room [ROOM_LEN]; }


      const sc_userdata [] =
      {{ "Verne Nilsen", "123" },

      { "Carlos Tang", "77" }

      ,

      { "Bronwyn Hawcroft" , "119" }

      ,

      { "Alessandro Hanssen" , "32" }

      ,

      { "Andrew John Bakken" , "54" }

      ,

      { "Vanessa Weatherley" , "85" }

      ,

      { "Rebecca Dickens" , "17" }

      ,

      { "David Bradley" , "42" }

      ,

      { "Knut Walters" , "25" }

      ,
      { "Andrea Jones" , "34" }};

      for
      (struct userdata const *row (sc_userdata);
      row < (&sc_userdata) [01]; ++row) {
      char const *const l_data [] =

      { row -> name, row -> room }

      ;
      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>

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jerome.pasion Jerome Pasion
            yecril71pl Christopher Yeleighton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes