[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);@
    become
    @QSqlQuery *myQuery = new QSqlQuery(*myDb);@
    and everithing is fine now..
    just do not forget *--


  • Lifetime Qt Champion

    Hi,

    Please have a look at "QSqlDatabase's documentation":http://qt-project.org/doc/qt-5/qsqldatabase.html#details to see the proper use of that class


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.