Results 1 to 4 of 4

Thread: QTableWidget to QSqltable

  1. #1
    Join Date
    Nov 2008
    Posts
    39
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QTableWidget to QSqltable

    Hi,
    I have complete data read from a file in QTableWidget, now I want to save the QTableWidget as it is into a database and then use.

    Thanks & regards
    Manmohan

  2. #2
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget to QSqltable

    That is maybe not the best way to do it.

    Why not try the following approach:
    create a database and table
    create a QSqlTableModel and QSqlRecord for the model
    read the file into a QTextStream
    loop through the stream load the records
    insert the data from the model into the table
    Create a QTableView to display the data from the model

    See the model/view programming doc here: http://doc.trolltech.com/4.5/model-v...ogramming.html

  3. #3
    Join Date
    Nov 2008
    Posts
    39
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableWidget to QSqltable

    Header columns are not same all the time so its hard to read data and store in database table format. I wanted to create a data base which gets its no of columns by reading the file.

  4. #4
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget to QSqltable

    Then why not just read the first record in the file to see how many fields you need in the database table, then proceed to create the rest as above?

Similar Threads

  1. Replies: 3
    Last Post: 6th May 2010, 04:02
  2. QTableWidget
    By kishore7771 in forum Newbie
    Replies: 3
    Last Post: 6th October 2009, 06:46
  3. QTableWidget
    By rick_st3 in forum Newbie
    Replies: 1
    Last Post: 20th June 2008, 10:05
  4. QTableWidget
    By alexx in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2007, 22:00
  5. QTableWidget
    By chak_med in forum Qt Programming
    Replies: 1
    Last Post: 17th May 2006, 15:53

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.