Important: Please read the Qt Code of Conduct -

[SOLVED] Problems with pointers between QSqlQuerry and QSqlDatabase

  • i have a smole piece of code that create me a lot f trouble.. and I do nt understand why.. if any of yoou can explayn that will be greatfull..
    //to create QSqlDatabase i have
    QSqlDatabase *myDb = new QSqlDatabase();
    .......// and all orther stuff for connection - is ok is working is open.

    //to create a querry now
    QSqlQuery *myQuery = new QSqlQuery(myDb);
    //my sql query and querry exec...

    but there is giving me this error

    in the static member function 'static QSqlQuery* myClassName::myFunctionName(); no matching function for call to QSqlQuery::QSqlQuery(QSqlDatabase*)

  • ok.. I've solved myself is just a simple pointer mistake.. so.. from..
    @QSqlQuery *myQuery = new QSqlQuery(myDb);@
    @QSqlQuery *myQuery = new QSqlQuery(*myDb);@
    and everithing is fine now..
    just do not forget *--

  • Lifetime Qt Champion


    Please have a look at "QSqlDatabase's documentation": to see the proper use of that class

Log in to reply