[SOLVED]Model/View read



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



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



  • Yes I Used QSFPM and It worked just fine
    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.