Results 1 to 2 of 2

Thread: Error QSqlTableModel

  1. #1
    Join Date
    Nov 2012
    Posts
    24
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Error QSqlTableModel

    Hello,

    When I run the code below, I get the error:
    error: C2664: 'QSqlTableModel::QSqlTableModel(QObject *,QSqlDatabase)' : cannot convert parameter 1 from 'getData *const ' to 'QObject *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


    What is wrong?

    Qt Code:
    1. class getData
    2. {
    3. public:
    4. getData(const QDate &date, const QSqlDatabase &dbase);
    5. QVector<QString> inputData();
    6. QMap<QString,double> setParams();
    7. private:
    8. QDate date_;
    9. QSqlDatabase dbase_;
    10. QSqlTableModel *model_;
    11. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. getData::getData(const QDate &date, const QSqlDatabase &dbScenarios) : date_(date), dbase_(dbase)
    2. {}
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QVector<QString> getData::inputData(){
    2. QString filter="";
    3. model_ = new QSqlTableModel(this, dbase_);
    4. modelScenarios->setTable("Scenarios");
    5. modelScenarios->setFilter(filter);
    6. modelScenarios->select();
    7. while(modelScenarios->canFetchMore()){
    8. modelScenarios->fetchMore();
    9. }
    10. ….
    11. return ….
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Arend; 5th December 2013 at 16:22.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,456
    Thanked 271 Times in 266 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error QSqlTableModel

    In line 3. this gets You pointer to getData object and QSqlTableModel constructor needs a pointer to QObject.

Similar Threads

  1. Error Modifiying a record of a QSqlTableModel
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 28th July 2011, 10:41
  2. Replies: 8
    Last Post: 30th March 2011, 20:06
  3. QSqlTableModel
    By codeman in forum Qt Programming
    Replies: 7
    Last Post: 4th May 2009, 11:04
  4. QSqlTableModel and LIKE
    By JeanC in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2008, 08:45
  5. QSqlTableModel Help pls
    By munna in forum Newbie
    Replies: 1
    Last Post: 7th March 2006, 19:40

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.