Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Error in QStandardItemModel.appendRow

[Solved] Error in QStandardItemModel.appendRow

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 5.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    Dear all,

    I use following code to appendRow List of QStandardItem, but only first row of data is appended.
    I can't find out what's wrong with that code.
    Plz help me..

    @QList<QStandardItem*> items;

    item1 = new QStandardItem("text1");
    item2 = new QStandardItem("text2");
    item3 = new QStandardItem("text3");

    items.append(item1);
    items.append(item2);
    items.append(item3);

    QStandardItemModel.appendRow(items);@

    Debug:
    items.count is 3
    QStandardItemModel.rowCount is 1

    Thanks

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Isn't it more logical to do for each item in items appendrow(item)?

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zither
        wrote on last edited by
        #3

        Thanks for your advice.

        Firstly, I try to add item for each items with appendRow(item) method but very bad & slow performance.
        I would like to know that can I speed up by adding items to List & set them to a model.

        So, I try with appendRow(items) method.

        Thanks

        1 Reply Last reply
        0
        • L Offline
          L Offline
          ludde
          wrote on last edited by
          #4

          Documentation for appendRow() clearly states that it "Appends a row containing items. If necessary, the column count is increased to the size of items." So what you get is one row with three columns.
          To do what you want to do, use appendColumn() instead.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved