Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Display some data after uploading csv file



  • Hello ,
    Currently , i upload a csv file and i display all the data in a tablewidget .
    i want to display some line of my loaded csv file in another tablewidget .
    How to do this
    thank you



  • @dziko147 said in Display some data after uploading csv file:

    Currently , i upload a csv file and i display all the data in a tablewidget .
    i want to display some line of my loaded csv file in another tablewidget .

    The same way as however you say you currently do it? Copy whatever data you want from one QTableWidget to another.



  • thanks for your reply , but when you use this solution you must reload the file .
    What i want is loading the file for only one time then display some lines on another tablewidget .
    I hopeb that my question is clear :)



  • @dziko147

    Then load it just once and put (= copy) the data in both tableWidgets. There should be no problem at all.



  • Use QSortFilterProxyModel to filter out the rows you don't want in the second view and call QTableView::setModel passing the proxy



  • who can give me example or source code please .
    thank you



  • in the header

    private:
    QSortFilterProxyModel *m_filterProxy;
    QTableView* m_secondTable;
    

    in the source

    m_filterProxy = new QSortFilterProxyModel(this);
    m_filterProxy->setSourceModel(tableWidget.model());
    m_filterProxy->setFilterRegularExpression(QStringLiteral("^[Aa].*")); // only show items starting with A
    m_secondTable = new QTableView(this);
    m_secondTable->setModel(m_filterProxy);
    // m_secondTable->show();
    

Log in to reply