Results 1 to 3 of 3

Thread: Compilation problem with QSqlQuery::bindValue()

  1. #1
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Compilation problem with QSqlQuery::bindValue()

    I'm having a strange problem with the QSqlQuery::bindValue() sintax, my QT code is show above:

    #include "ManipulaTipos.h"

    #include <iostream>

    using namespace std;

    ManipulaTipos::ManipulaTipos(void){
    }

    void ManipulaTipos::adiciona(QString tabela,QString codigo,QString nome){
    expressao="INSERT INTO ";
    expressao.append(tabela);
    expressao.append(" (codigo,nome) VALUES (:codigo, :nome)");
    query.prepare(expressao);
    query.bindValue(":codigo", codigo);
    query.bindValue(":nome", nome);
    query.exec();
    }

    QList<QStringList> ManipulaTipos::listar(QString tabela){
    QString codigo;
    QString nome;
    QStringList registro;
    expressao="SELECT * FROM ";
    expressao.append(tabela);
    query.prepare(expressao);
    query.exec();
    while(query.next()){
    codigo=query.value(0).toString();
    nome=query.value(1).toString();
    registro<<codigo;
    registro<<nome;
    lista << registro;
    }
    return(lista);
    }

    void ManipulaTipos::remove(QString tabela,QString indice){
    expressao="DELETE FROM ";
    expressao.append(tabela);
    expressao.append(" WHERE codigo==:indice");
    query.prepare(expressao);
    query.bindValue(":indice",indice);
    query.exec();
    }

    void ManipulaTipos::atualiza(QString tabela,QString indice,QString novo){
    expressao="UPDATE ";
    expressao.append(tabela);
    expressao.append(" SET nome=:novo WHERE codigo==:indice");
    query.prepare(expressao);
    query.bindValue(":novo",novo);
    query.bindValue(":indice",indice);
    query.exec();
    }

    When I do make this message come:

    brevleq@brevleq:~/caixa$ make
    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.3.0/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.3.0/include/QtCore -I/usr/local/Trolltech/Qt-4.3.0/include/QtCore -I/usr/local/Trolltech/Qt-4.3.0/include/QtGui -I/usr/local/Trolltech/Qt-4.3.0/include/QtGui -I/usr/local/Trolltech/Qt-4.3.0/include/QtSql -I/usr/local/Trolltech/Qt-4.3.0/include/QtSql -I/usr/local/Trolltech/Qt-4.3.0/include -I. -Ibd -Itela_principal -Icadastro -Ilistagem/lista -Ilistagem/lista_tipos -Icriacao_caixa -I. -I. -o ManipulaTipos.o bd/ManipulaTipos.cpp
    bd/ManipulaTipos.cpp: In member function 'void ManipulaTipos::adiciona(QString, QString, QString)':
    bd/ManipulaTipos.cpp:15: error: no matching function for call to 'QSqlQuery::bindValue(const char [8], QString&)'
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:91: note: candidates are: void QSqlQuery::bindValue(const QString&, const QVariant&, QSql::ParamType)
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:92: note: void QSqlQuery::bindValue(int, const QVariant&, QSql::ParamType)
    bd/ManipulaTipos.cpp:16: error: no matching function for call to 'QSqlQuery::bindValue(const char [6], QString&)'
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:91: note: candidates are: void QSqlQuery::bindValue(const QString&, const QVariant&, QSql::ParamType)
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:92: note: void QSqlQuery::bindValue(int, const QVariant&, QSql::ParamType)
    bd/ManipulaTipos.cpp: In member function 'QList<QStringList> ManipulaTipos::listar(QString)':
    bd/ManipulaTipos.cpp:29: error: invalid use of undefined type 'struct QVariant'
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qobject.h:45: error: forward declaration of 'struct QVariant'
    bd/ManipulaTipos.cpp:30: error: invalid use of undefined type 'struct QVariant'
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qobject.h:45: error: forward declaration of 'struct QVariant'
    bd/ManipulaTipos.cpp: In member function 'void ManipulaTipos::remove(QString, QString)':
    bd/ManipulaTipos.cpp:43: error: no matching function for call to 'QSqlQuery::bindValue(const char [8], QString&)'
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:91: note: candidates are: void QSqlQuery::bindValue(const QString&, const QVariant&, QSql::ParamType)
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:92: note: void QSqlQuery::bindValue(int, const QVariant&, QSql::ParamType)
    bd/ManipulaTipos.cpp: In member function 'void ManipulaTipos::atualiza(QString, QString, QString)':
    bd/ManipulaTipos.cpp:52: error: no matching function for call to 'QSqlQuery::bindValue(const char [6], QString&)'
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:91: note: candidates are: void QSqlQuery::bindValue(const QString&, const QVariant&, QSql::ParamType)
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:92: note: void QSqlQuery::bindValue(int, const QVariant&, QSql::ParamType)
    bd/ManipulaTipos.cpp:53: error: no matching function for call to 'QSqlQuery::bindValue(const char [8], QString&)'
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:91: note: candidates are: void QSqlQuery::bindValue(const QString&, const QVariant&, QSql::ParamType)
    /usr/local/Trolltech/Qt-4.3.0/include/QtSql/qsqlquery.h:92: note: void QSqlQuery::bindValue(int, const QVariant&, QSql::ParamType)
    make: ** [ManipulaTipos.o] Erro 1

    I can't understand!! I looked 4 times in QT help and I think the sintax is correct!!

  2. #2
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Compilation problem with QSqlQuery::bindValue()

    I've solved the problem!!

    I forgot include the QVariant Library!!

  3. The following user says thank you to brevleq for this useful post:

    Big_Stone88 (5th June 2018)

  4. #3
    Join Date
    Nov 2013
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Default Re: Compilation problem with QSqlQuery::bindValue()

    Thanks i had the same probleme and now i fixed it thanks to you

Similar Threads

  1. sub-dir compilation problem
    By Salazaar in forum Newbie
    Replies: 13
    Last Post: 2nd November 2007, 21:48
  2. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 14:18
  3. qt4 compilation problem
    By aegis in forum Installation and Deployment
    Replies: 9
    Last Post: 22nd February 2007, 23:10
  4. Problem and solution about QSA 1.2.0 compilation
    By Dwarf007 in forum Installation and Deployment
    Replies: 5
    Last Post: 7th March 2006, 16:52
  5. Compilation problem, don't know why
    By yellowmat in forum Newbie
    Replies: 6
    Last Post: 2nd March 2006, 15:36

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.