Results 1 to 4 of 4

Thread: How can i load/display csv file in QTableWidget?(long read, sorry)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    8
    Thanks
    7
    Qt products
    Qt4

    Default How can i load/display csv file in QTableWidget?(long read, sorry)

    So what i am trying to do is make my app that has spreadsheet(qtablewidget) as mainwindows central widget open and display csv files in such a way that every word in csv file loaded by my app(all words in csv file are separated by comma) is displayed in QTableWidget cell in natural flow so on the end my spreadsheet would display each word from csv file in its own cell in spreadsheet by natural flow as it looks in csvreaders.



    Currently i am studying QT Programming book (ver 2) and i must say i am having a rought time, i am rereading, memorizing, trying to figure this book and even its sometimes really a pain i am not giving up.

    What did i learn so far following the spreadsheet example is how to write file from my spreadsheet(qtablewidget) and how to open that file.

    The logic that program follows for doing this is simply - Iterate over each row and column, specify each column, get the data from it as text and give that text to Qstring for writting in a file and with row_colun iteration write row, column and its string to a file with QDataStream in a sequence so on the end file written ends like

    row 1 - column 1 - string, row 1 -column 2 - string, row 1 - column 3 - string and so on... all the way to the end of last column in table


    Now to read this and display it on widget book example is using while loop and puts (!in.atEnd()) as condition so if input streaming is not done it will display each cell that is written inside file on my spreadsheet widget.

    It does so because each row and column is written as int number inside the file, it takes these numbers in order starting with(row 1 - column 1) passes these as arguments to a function in my class that accordingly writes all text(string) in row and column it gets and on the end bam every text is in every cell written and my table is written, phew this reminded me how much headaches i had before simply figuring how this works. Maybe i am dumb or this book is just not suited for starters but i am learning alot.

    So, why am i writting this on the end. Because i cant figure the logic that QDataStream uses. I see how i can read my own Qtable spreadsheet files because each time i write data with QDataStream i will write inside it a row, column, text and use my function to display this data in table because it gets required parameters for it but HOW IN THE WORLD...

    am i going to make my application load some .csv that lets say i download from the Web to open it and display it, how if i have no clue what is inside it? (the low level data) because i am assuming when some csv program saves csv file and some guy emails(example) that file to me it surely doesnt have same low level data(like my spreadsheet files do) that i can simply pass it to my app and its functions for displaying(loading), so what am i gonna do then, is it possible to somehow achieve this?

    Sorry for long read but i tried to be specific so you can understand my situation better, thank you for reading
    Last edited by msimurin; 15th March 2010 at 03:05.

Similar Threads

  1. read QTableWidget cells
    By navid in forum Newbie
    Replies: 8
    Last Post: 4th April 2010, 10:40
  2. How to read rtf file and display it?
    By sunnysun520 in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2009, 14:48
  3. Layout long text in QTableWidget
    By Tamtam in forum Newbie
    Replies: 0
    Last Post: 13th February 2009, 15:09
  4. is qt phonon can read realmedia file and divx file
    By fayssalqt in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2009, 15:42
  5. How to Read and display BMP image using QT
    By agsrinivasan in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2007, 07:14

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.