×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Question How to pass QSqlTableModel to ListView?

    I'm trying to do something like this:
    Code:
    QSqlTableModel *model = new QSqlTableModel;
    model->setTable(table);
    model->select();
    rootObject->setProperty("myModel", model);
    But this is the error I get (pointing to rootObject):
    'QVariant::QVariant(void*)' is private
    within this context
    I'm using QmlApplicationViewer and other than this it works. I can set property to other things just fine. It's only with QSqlTableModel I have a problem.

    Any ideas what I'm doing wrong or missing?

    Cheers
    http://www.ic-mobile.com/

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to pass QSqlTableModel to ListView?

    Hmm... Anyone? Or perhaps someone has a better idea how I should pass the data from C++ and SQLite to QML and ListView?

    Any help would be greatly appreciated.

    Cheers
    http://www.ic-mobile.com/

  3. #3
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: How to pass QSqlTableModel to ListView?

    Quote Originally Posted by Sasler View Post
    Hmm... Anyone? Or perhaps someone has a better idea how I should pass the data from C++ and SQLite to QML and ListView?

    Any help would be greatly appreciated.

    Cheers
    Since no one has replied, can I ask, why don't you read the database and populate your model in your QML file ?
    -CarlosDL

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to pass QSqlTableModel to ListView?

    Quote Originally Posted by cadlg View Post
    Since no one has replied, can I ask, why don't you read the database and populate your model in your QML file ?
    I suppose that would be one way of doing it. But I just rather do all the database stuff in C++, since I'm much more familiar with it and I can reuse my already made classes for manipulating the data. I could, of course, just do the manipulating in C++ and then just read the database in QML, but I wonder if it's very efficient to access the same database in C++ and QML separately.
    http://www.ic-mobile.com/

Similar Threads

  1. How to create Custome ListView control?
    By narendar_discover in forum [Archived] Beginning Qt
    Replies: 2
    Last Post: 2011-02-26, 11:15
  2. How to define a vertical scrolling offset in a listView?
    By evgeny_123 in forum [Archived] Qt Quick
    Replies: 8
    Last Post: 2011-02-25, 15:21
  3. Replies: 0
    Last Post: 2010-12-07, 11:34
  4. How to get Listview selected item
    By amol_benare604 in forum Qt
    Replies: 1
    Last Post: 2010-11-18, 09:25
  5. Replies: 3
    Last Post: 2009-06-26, 15:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×