IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Qt Discussion :

Qhttp erreur lors de la compilation.


Sujet :

Qt

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Âge : 32
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 264
    Points : 52
    Points
    52
    Par défaut Qhttp erreur lors de la compilation.
    Bonjour,

    je suis entrain de refaire une parti de mon programme avec des classes Qt pour qu'il soit plus portable car actuellement j'ai une classe que j'ai fait moi même mais je me suis rendu compte qu'elle n'est pas compatible avec linux...

    Donc j'utilise la classe QHttp mais j'ai un petit souci vu que je ne l'ai jamais encore utilisé...

    J'ai mis dans mon fichier .pro : QT += network et dans mon fichier .cpp j'ai mis :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    #include <QtNetwork>
    #include <QHttp>
    Ensuite dans mon fichier .cpp j'ai mis :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
     
    void Tool::on_pushButton_connection_clicked()
    {
        QString PostVariable = "username=";
        PostVariable+=uiConfig.lineEdit_2->text();
        PostVariable+="&password=";
        PostVariable+=QCryptographicHash::hash(uiConfig.lineEdit->text().toUtf8(),QCryptographicHash::Sha1).toHex();
        PostVariable+=uiConfig.lineEdit->text();
     
        http = new QHttp(this); // variable de la class Http
     
        QHttpRequestHeader header("POST", "www.Site.fr");
        header.setValue("Host", "www.Site.fr");
        http->setHost("www.Site.fr");
        http->request(header);
        http->post("/page.php", PostVariable.toStdString());
     
        if(QHttp::NoError)
        {
            QMessageBox::information(0, tr("Site"), tr("Vous êtes connecté !"));
        }
        else
        {
            QMessageBox::information(0, tr("Site"), tr("Une erreur c'est produite."));
        }
    }
    Et dans ma page .h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    ...
    class QHttp;
     
    class Tool : public QSystemTrayIcon
    {
    	Q_OBJECT
     
    	public:
    		Tool();
     
    	private slots:
     
            void on_pushButton_connection_clicked();
     
     
    	private:
     
            QHttp *http;
    };
    ...

    Et j'ai cette erreur je ne vois pas pourquoi !?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
     
    mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `C:/Sources2'
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
    DQT_DLL -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEE
    DS_QMAIN -I"..\Qt\4.4.3\include\QtCore" -I"..\Qt\4.4.3\include\QtCore" -I"..\Qt\
    4.4.3\include\QtNetwork" -I"..\Qt\4.4.3\include\QtNetwork" -I"..\Qt\4.4.3\includ
    e\QtGui" -I"..\Qt\4.4.3\include\QtGui" -I"..\Qt\4.4.3\include" -I"." -I"c:\Qt\4.
    4.3\include\ActiveQt" -I"debug" -I"." -I"..\Qt\4.4.3\mkspecs\win32-g++" -o debug
    \main.o main.cpp
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
    DQT_DLL -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEE
    DS_QMAIN -I"..\Qt\4.4.3\include\QtCore" -I"..\Qt\4.4.3\include\QtCore" -I"..\Qt\
    4.4.3\include\QtNetwork" -I"..\Qt\4.4.3\include\QtNetwork" -I"..\Qt\4.4.3\includ
    e\QtGui" -I"..\Qt\4.4.3\include\QtGui" -I"..\Qt\4.4.3\include" -I"." -I"c:\Qt\4.
    4.3\include\ActiveQt" -I"debug" -I"." -I"..\Qt\4.4.3\mkspecs\win32-g++" -o debug
    \tool.o tool.cpp
    tool.cpp: In member function `void Tool::on_pushButton_connection_clicked()':
    tool.cpp:194: error: `setHost' has not been declared
    tool.cpp:194: error: request for member of non-aggregate type before '(' token
    tool.cpp:195: error: `request' has not been declared
    tool.cpp:195: error: request for member of non-aggregate type before '(' token
    tool.cpp:196: error: `post' has not been declared
    tool.cpp:196: error: request for member of non-aggregate type before '(' token
    mingw32-make[1]: *** [debug/tool.o] Error 1
    mingw32-make[1]: Leaving directory `C:/Sources2'
    mingw32-make: *** [debug] Error 2
    Merci de votre aide !

  2. #2
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2007
    Messages : 20
    Points : 24
    Points
    24
    Par défaut
    Salut,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
        http.setHost("www.site.fr");
        http.request(header);
        http.post("/page.php", PostVariable.toStdString());
    Tu utilise un pointeur pour http donc il faut mettre -> et non un .

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
        http->setHost("www.site.fr");
        http->request(header);
        http->post("/page.php", PostVariable.toStdString());
    Je pense que c'est la seule erreur j'ai pas vraiment regardé

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Âge : 32
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 264
    Points : 52
    Points
    52
    Par défaut
    Merci je suis carrément passer à coté !
    Quand je fais ça je me retrouve avec cette erreur ^^ :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
     
    mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `C:/Sources2'
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
    DQT_DLL -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEE
    DS_QMAIN -I"..\Qt\4.4.3\include\QtCore" -I"..\Qt\4.4.3\include\QtCore" -I"..\Qt\
    4.4.3\include\QtNetwork" -I"..\Qt\4.4.3\include\QtNetwork" -I"..\Qt\4.4.3\includ
    e\QtGui" -I"..\Qt\4.4.3\include\QtGui" -I"..\Qt\4.4.3\include" -I"." -I"c:\Qt\4.
    4.3\include\ActiveQt" -I"debug" -I"." -I"..\Qt\4.4.3\mkspecs\win32-g++" -o debug
    \tool.o tool.cpp
    tool.cpp: In member function `void Tool::on_pushButton_connection_clicked()':
    tool.cpp:196: error: no matching function for call to `QHttp::post(const char[18
    ], std::string)'
    ../Qt/4.4.3/include/QtNetwork/../../src/network/access/qhttp.h:219: note: candid
    ates are: int QHttp::post(const QString&, QIODevice*, QIODevice*)
    ../Qt/4.4.3/include/QtNetwork/../../src/network/access/qhttp.h:220: note:
              int QHttp::post(const QString&, const QByteArray&, QIODevice*)
    mingw32-make[1]: *** [debug/tool.o] Error 1
    mingw32-make[1]: Leaving directory `C:/Sources2'
    mingw32-make: *** [debug] Error 2

  4. #4
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2007
    Messages : 20
    Points : 24
    Points
    24
    Par défaut
    Ta variable PostVariable est un QString que tu modifie en std::string dans ton http->post or dans la doc de QHttp post() ne prend ni de QString ou std::string en 2ème paramètres :

    int QHttp::post ( const QString & path, QIODevice * data, QIODevice * to = 0 )
    int QHttp::post ( const QString & path, const QByteArray & data, QIODevice * to = 0 )

    Après je ne peux pas vraiment t'aider n'ayant jamais utilisé QHttp.
    De plus "/page.php" est pris comme un char or il devrait être dans un QString

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Âge : 32
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 264
    Points : 52
    Points
    52
    Par défaut
    Honnêtement la je suis perdu...

    Je pense pas qu'il est pris comme un char car dans la doc Qt il y a :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    http->post("register.html", data);

  6. #6
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2007
    Messages : 20
    Points : 24
    Points
    24
    Par défaut
    Dans l'erreur : error: no matching function for call to `QHttp::post(const char[18], std::string)
    il a l'air de le voir comme un char[] mais je pense surtout comme dit dans mon message au dessus est que ton 2ème paramètres est faux.

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Âge : 32
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 264
    Points : 52
    Points
    52
    Par défaut
    Je ne comprends pas par exemple je fais :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    classe::classe()
    {
        QObject::connect(&req, SIGNAL(done(bool)), this, SLOT(affiche(bool)));
        QObject::connect(&req, SIGNAL(requestFinished(int, bool)), this, SLOT(fin(int, bool)));
     
        req.setHost("www.site.fr");
     
        QHttpRequestHeader header("POST","http://www.site.fr/");
        header.setValue("Host","www.site.fr");
        header.setValue("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14");
        req.post("/page.php", "username=PSEUDO&password=MDP");
     
        req.request(header);
     
        show();
    }
    Logiquement ça devrai m'afficher les infos qui sont accessible que par envoie du pseudo et mot de passe par méthode post mais rien ne se passe j'ai l'impression que la méthode post ne passe pas...

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 09/04/2015, 11h01
  2. Erreur lors de la compilation de MySQL
    Par webrider dans le forum SUSE
    Réponses: 2
    Dernier message: 06/03/2007, 11h21
  3. Erreur lors de la compilation avec OmniORB
    Par JohnKwada dans le forum CORBA
    Réponses: 1
    Dernier message: 07/09/2006, 17h34
  4. erreur lors de la compilation
    Par ksoft dans le forum MFC
    Réponses: 2
    Dernier message: 02/05/2006, 15h40
  5. Réponses: 4
    Dernier message: 22/02/2006, 14h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo