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 :
Ensuite dans mon fichier .cpp j'ai mis :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 #include <QtNetwork> #include <QHttp>
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
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.")); } }
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 !?
Merci de votre aide !
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
Partager