Results 1 to 20 of 23

Thread: How to populate a QTableView using data in a .txt file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Join Date
    Sep 2015
    Posts
    25
    Thanks
    5

    Default Re: How to populate a QTableView using data in a .txt file

    Hi
    That's true, but when I tried doing that I am getting an error.

    Cannot convert from QStandardItemModel ** to QAbstractItemModel*.
    Change:
    QStandardItemModel model=new QStandardItemModel(10,3, this);

    Thanks


    Added after 4 minutes:


    Correction
    QStandardItemModel *model=new QStandardItemModel(10,3,this);

    If I do the following; The exe stops working giving an error

    if(file.open(QIODevice::ReadOnly)){
    QString line;
    QStringList line_data;

    while(!file.atEnd()){
    line=file.readLine();
    line_data=line.split(";", QString::SkipEmptyParts);
    for(int j=0;j<line_data.size();j++){
    QString m_prop=line_data.at(j);
    QTableWidgetItem *item=new QTableWidgetItem(m_prop);
    ui->tableWidget->setItem(line_count,j,item);
    }
    line_count++;

    }
    }


    Added after 1 14 minutes:


    why do I need to create 3 different data structures just to simply acces strings from a file, parse them and display them onto a Table?

    I am unfortunately still unable to find a solution to this.
    Last edited by newtoQ_s; 22nd September 2015 at 12:29.

Similar Threads

  1. Replies: 0
    Last Post: 28th January 2013, 09:14
  2. how to populate data in QTableWidget
    By gauravg in forum Qt-based Software
    Replies: 1
    Last Post: 25th March 2011, 12:50
  3. Replies: 3
    Last Post: 1st February 2011, 11:57
  4. How to populate Combobox in QTableView
    By ronak.vashi in forum Newbie
    Replies: 8
    Last Post: 4th December 2010, 17:09
  5. How to populate delegate with model data.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2008, 09:31

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.