Results 1 to 6 of 6

Thread: CSV file content to QTablewidget view

  1. #1
    Join Date
    Oct 2010
    Location
    India
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default CSV file content to QTablewidget view

    Hi,

    Is there any one to solve the listed problem below,

    Requirement : I want to read the CSV file and displaying to Table view.

    Is QT having any default class for reading CSV files ? and How can we display the string content inside Table?

    Thanks in advance

  2. #2
    Join Date
    Oct 2010
    Location
    India
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: CSV file content to QTablewidget view

    Adding what I tired to insert table content inside Table,

    Qt Code:
    1. while(tableIndex<tableSize)
    2. {
    3. item->setText(obj.number);
    4. ui->tableWidget->setItem(tableIndex, 0, item);
    5.  
    6. item1->setText(obj.aritst);
    7. ui->tableWidget->setItem(tableIndex,1, item1);
    8.  
    9. item2->setText(obj.producer);
    10. ui->tableWidget->setItem(tableIndex,2, item2);
    11.  
    12. item3->setText(obj.title);
    13. ui->tableWidget->setItem(tableIndex,3, item3);
    14.  
    15. item4->setText(obj.lyrics);
    16. ui->tableWidget->setItem(tableIndex,4, item4);
    17. }
    To copy to clipboard, switch view to plain text mode 

    It is working fine. But the problem is, I am using pointer object to insert an item. If i want to insert 5row 10 column means 5X10 = 500 object pointers I have to use .
    Last edited by Lykurg; 21st October 2010 at 08:18. Reason: missing [code] tags

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: CSV file content to QTablewidget view

    There is no problem having 500 items on the heap. But if you don't like it, make a custom model.

    EDIT: Also have a look at linqxt: QxtCsvModel

  4. #4
    Join Date
    Oct 2010
    Location
    India
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: CSV file content to QTablewidget view

    Thanks Lykurg.

    One more solution also neededed,

    We are getting some search result one by one as a String from CSV file and we need add them inside table . How can we do this?

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: CSV file content to QTablewidget view

    adjust the dimensions of your table and insert the new item, or model based: just add an item to the model, and the view will handle all necessary things.

  6. #6
    Join Date
    Oct 2010
    Location
    India
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: CSV file content to QTablewidget view

    Thank u very much!~~


    One stupid question, I gonna ask !

    Qt Code:
    1. for (int row=0;row<10000; row++)
    2. for (int col=0;col<6; col++)
    3. ui->tableWidget->setItem(row, col,new QTableWidgetItem(QString::number(col)));
    To copy to clipboard, switch view to plain text mode 

    Here I am creating dynamic object using for 'QTableWidgetItem' using 'new' operator!

    Is there any way to find the size of the entire Table item?

    Please help me here!

Similar Threads

  1. set content(&file)
    By rk0747 in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2010, 08:31
  2. Replies: 1
    Last Post: 1st February 2010, 18:42
  3. How to modify the content of text file
    By grsandeep85 in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2009, 10:23
  4. Saving QLabel content in a file
    By Caius Aérobus in forum Newbie
    Replies: 1
    Last Post: 29th October 2008, 17:03
  5. Replies: 1
    Last Post: 16th January 2008, 11:48

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.