Results 1 to 3 of 3

Thread: function to return QSQLquerymodel

  1. #1
    Join Date
    Sep 2012
    Posts
    44
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default function to return QSQLquerymodel

    I want to make function returning qsqlquerymodel like this:

    Qt Code:
    1. QSqlQueryModel Controller::getPartners(){
    2.  
    3. QSqlQueryModel *model = new QSqlQueryModel(this);
    4. model->setQuery("SELECT ID, Name, Bulstat FROM partners");
    5. return model;
    6. }
    To copy to clipboard, switch view to plain text mode 
    i got the following error:
    no viable conversion from 'QSqlQueryModel *' to 'QSqlQueryModel' return model;

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: function to return QSQLquerymodel

    Quote Originally Posted by cpuinthebrain View Post
    i got the following error:
    no viable conversion from 'QSqlQueryModel *' to 'QSqlQueryModel' return model;
    Your method has a return type of QSqlQueryModel, your local "model" variable is a pointer to a QSqlQueryModel, a.k.a. QSqlQueryModel*

    Change the return type of your function.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: function to return QSQLquerymodel

    try

    QSqlQueryModel * Controller::getPartners(){

    QSqlQueryModel *model = new QSqlQueryModel(this);
    model->setQuery("SELECT ID, Name, Bulstat FROM partners");
    return model;
    }

Similar Threads

  1. QSqlQueryModel ‘s method rowcount() return 256
    By liuqin820222 in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2013, 10:16
  2. Replies: 1
    Last Post: 2nd January 2013, 10:48
  3. How to return QString from function
    By Rondle in forum Newbie
    Replies: 3
    Last Post: 21st November 2012, 19:51
  4. Replies: 4
    Last Post: 2nd April 2010, 11:04
  5. Function return
    By waynew in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2009, 01:52

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.