Results 1 to 2 of 2

Thread: How to save a Tablewidget in qt

  1. #1
    Join Date
    Apr 2016
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to save a Tablewidget in qt

    Hi,

    It will be a great help if anybody can assist me .
    I have a Tablewidget which gets poulated with dynamic value each time we run it. In file menu i have save as and open entries. I want to save these data and open it as a tablewidget again.
    Thanks in advance,
    Namitha Pavithran

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to save a Tablewidget in qt

    Easiest way is to save the contents as an ASCII CSV file. Create the CSV file, then for each row in the table, create a comma-separated row in the CSV file, one text field for each column. If any cell is empty, be sure to put a ",," empty field in the CSV file, otherwise you will end up with a mis-aligned table when you read it back in.

    To read in, open the CSV file, then read each line into a QString. Use QString::split() to split the line into a QStringList of entries. Be sure to set the KeepEmptyParts flag. For line, add a row to the table, then for each entry in the string list, add a cell in that row.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QVariant : save : unable to save type 128
    By capbee in forum Qt Programming
    Replies: 0
    Last Post: 15th July 2013, 10:10
  2. Replies: 1
    Last Post: 30th November 2012, 18:54
  3. Replies: 4
    Last Post: 30th May 2012, 00:37
  4. TableWidget
    By matulik in forum Newbie
    Replies: 6
    Last Post: 2nd May 2010, 19:47
  5. searching in a TableWidget
    By peace_comp in forum Qt Programming
    Replies: 1
    Last Post: 17th May 2008, 17:17

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.