Results 1 to 3 of 3

Thread: SQLite problem loading from file and display result in table

  1. #1
    Join Date
    Mar 2009
    Posts
    104
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default SQLite problem loading from file and display result in table

    What i want is to load .sqlite file and dimply query in table.
    Unfortunately no table is displayed, just empty window.
    Database file is in the project main folder.


    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    2.  
    3. //db.setDatabaseName(QApplication::applicationDirPath() + QDir::separator() + "faktura.sqlite");
    4. db.setDatabaseName("faktura.sqlite");
    5. db.open();
    6.  
    7.  
    8.  
    9. model->setQuery("SELECT customer_id,name, address FROM customers");
    10. model->setHeaderData(0, Qt::Horizontal, QObject::tr("Field 1"));
    11. model->setHeaderData(1, Qt::Horizontal, QObject::tr("Field 2"));
    12. model->setHeaderData(2, Qt::Horizontal, QObject::tr("Field 3"));
    13.  
    14.  
    15.  
    16. QTableView *view = new QTableView;
    17. view->setModel(model);
    18. view->show();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: SQLite problem loading from file and display result in table

    what is db.open() returning?

  3. #3
    Join Date
    Mar 2009
    Posts
    104
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: SQLite problem loading from file and display result in table

    Problem solved.Everything wrks fine.All i did is to move the sqlite file in the debug directory.When i start the App from there everything works.

Similar Threads

  1. Problem loading .pdf file from qrc
    By el33t in forum Newbie
    Replies: 7
    Last Post: 28th August 2011, 05:44
  2. Why the result of display is not anti-aliased?
    By superwave in forum Qt Programming
    Replies: 3
    Last Post: 20th August 2011, 08:53
  3. Replies: 1
    Last Post: 20th September 2010, 07:46
  4. Replies: 4
    Last Post: 17th September 2010, 20:18
  5. How to display result
    By sksingh73 in forum Newbie
    Replies: 1
    Last Post: 7th June 2010, 08:39

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