Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Error: no matching function for call to 'QSqlQuery::addBindValue(std::string&)'
Forum Updated to NodeBB v4.3 + New Features

Error: no matching function for call to 'QSqlQuery::addBindValue(std::string&)'

Scheduled Pinned Locked Moved Language Bindings
2 Posts 2 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amarda_4
    wrote on last edited by
    #1

    I have this code

    @
    include <iostream>
    include<QSqlDatabase>
    include<QSqlQuery>
    #include <hyrje.h>
    using namespace std;
    class Votuesi
    {
    private:
    string v_id,emeri,mbiemer,atesia,qarkui,passi;
    public:
    bool lidhDatabase();
    void identifikohu();
    Votuesi(string ,string ,string );
    void publiko(){
    cout<<v_id<<qarkui<<passi;}};
    Votuesi::Votuesi(string a,string b,string c){
    emeri=a;
    qarkui=b;
    passi=c;}
    //Metode e cila ben te mundur lidhjen e programit me database-in
    bool lidhDatabase(){
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("evoting");
    db.setUserName("root");
    db.setPassword("");
    if (!db.open())
    return cout<<"Lidhja me database-in nuk mund te behet "; }
    return cout<<"Lidhja me database-in u krye me sukses";}
    //Metode e cila ben te mundur identifikimin e numrit te identitetit te votuesit
    void Votuesi::identifikohu(){
    QSqlQuery query;
    query.prepare("SELECT * FROM evoting WHERE emer = ? and qyteti = ? and pass = ?");
    query.addBindValue(this->emeri);
    query.addBindValue(this->qarkui);
    query.addBindValue(this->passi);
    query.exec();
    if(query.size()> 0){
    query.next();{
    else{
    cout<<"Te dhenat qe ju vendoset nuk jane te sakta";}}
    int main(){
    Votuesi votues("Amarda","Tirane","amarda");
    votues.lidhDatabase();
    votues.publiko();
    votues.identifikohu();}@

    what should I do to give the query my values of constructor ?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      "QSqlQuery::addBindValue":http://qt-project.org/doc/qt-5.0/qtsql/qsqlquery.html#addBindValue expects a valid Qt data type such as QString but you are providing STD string instead.

      http://anavi.org/

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved