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]Model/View read
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Model/View read

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    toho71
    wrote on last edited by
    #1

    Is it possible to read all the values from the QStandardItemModel but I only show a few of them in a QTableWidget.
    I need to reed the values to a file.

    Som code to show how I want to read the model and it's item.

    @ stream.setAutoFormatting(true);
    stream.writeStartDocument();
    stream.writeStartElement("TDU Settings");
    qDebug() <<model->rowCount();
    int g=0;
    for (int i = 0; i < model->rowCount();i++)
    {

         stream.writeStartElement("Setting");
         stream.writeAttribute("Text",model->data(model->index(i,0)).toString());
         stream.writeAttribute("Value",model->data(model->index(i,1)).toString());
         stream.writeAttribute("Obj",model->data(model->index(i,2)).toString());
         stream.writeEndElement(); // Setting
         g++;
     }
     qDebug() << g;
     stream.writeEndElement();//TDU
     stream.writeEndDocument();
    

    @

    The debug lines shows that the model contains 15 objects and the loop runs 15 times but the file only contains the values from the table.

    //I didn't put all my values to the model at the same time;

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Take a look into the proxy model concept as well. It would be a matter of fitering using a [[doc:QSortFilterProxyModel]].

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toho71
        wrote on last edited by
        #3

        Yes I Used QSFPM and It worked just fine
        Thanks

        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