Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] using a QlistView to display the contents of a Sqlite Database
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] using a QlistView to display the contents of a Sqlite Database

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Timmoth
    wrote on last edited by
    #1

    Hi all, i would like to use the QSqlQueryModel to interface between my QSqlDatabase and QListView. does anyone know how i would go about doing this?

    @
    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("my.db.sqlite");
    db.open();

    QSqlQuery query;
    query.exec("create table Players "
                    "(id integer primary key, "
                    "name varchar(20), "
                    "path varchar(30))"
               );
    
    query.exec("INSERT INTO Players (id, name, path)"
               "VALUES ('1', 'Tesco', 'C://tesco')");
    
    query.exec("INSERT INTO Players (id, name, path)"
               "VALUES ('2', 'Tesco', 'C://tesco')");
    
     model = new QSqlQueryModel;
     model->setQuery("SELECT name FROM Players");
     playerView->setModel(model);
    

    @
    that is the code i have so far - it does create the table and it does insert the two records into it - it just does not display them!

    thanks for any help / suggestions!
    regards
    Tim

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved