Partage
  • Partager sur Facebook
  • Partager sur Twitter

pb de compilation a cause d'une ligne

socket Qt

    24 mars 2008 à 15:44:47

    Bonjour à tous :D
    J'ai (encore :-° ) un probleme.
    Voici mon code:

    main.cpp
    1. #define HE
    2. #include <QApplication>
    3. #include <QFont>
    4. #include <QPushButton>
    5. #include <QLabel>
    6. #include <QTextEdit>
    7. #include <QtNetwork\QTcpServer>
    8. #include <QtCore\QObject>
    9. #include <QtCore\QString>
    10. #include <QTcpServer>
    11. #include <QTcpSocket>
    12. #include <QSound>
    13. #include "link.h"
    14. using namespace std;
    15. int main(int argc, char* argv[])
    16. {
    17.     QApplication app(argc, argv);
    18.     QWidget fenetrep; /**objet parent*/
    19.     /**Server et client*/
    20.     QTcpServer serveur;
    21.     QTcpSocket client;
    22.     serveur.listen(QHostAddress::Any,8282);
    23.     /**end*/
    24.     /**creation of objects link to the parent */
    25.     QPushButton BoutonSeb("Seb",&fenetrep);
    26.     QPushButton BoutonJer("Jer",&fenetrep);
    27.     QPushButton BoutonThi("Thi",&fenetrep);
    28.     QPushButton BoutonEnvoyer("Envoyer",&fenetrep);
    29.     QPushButton BoutonQuitter("Quitter",&fenetrep);
    30.     QLabel LabelConnection("Label d'info--Programme développé par Seb",&fenetrep);
    31.     QLabel LabelReceive("Label de reception",&fenetrep);
    32.     QTextEdit TextZone(&fenetrep);
    33.     link tra(&TextZone,&LabelConnection,&serveur,&client);
    34.     QSound son("ringin.wav",&fenetrep);
    35.     /**end */
    36.     /**Resize*/
    37.     fenetrep.resize(800,600);
    38.     BoutonJer.setGeometry(10, 10,50,30);
    39.     BoutonSeb.setGeometry(375, 10,50,30);
    40.     BoutonThi.setGeometry(740, 10,50,30);
    41.     BoutonEnvoyer.setGeometry(370, 500,75,45);
    42.     BoutonQuitter.setGeometry(370,550,75,45);
    43.     LabelConnection.setGeometry(10,30,775,45);
    44.     LabelReceive.setGeometry(10,60,775,300);
    45.     TextZone.setGeometry(10,450,775,45);
    46.     /**end*/
    47.     /**event*/
    48.         QObject::connect(&BoutonQuitter,SIGNAL(clicked()),&app,SLOT(quit()));
    49.         QObject::connect(&BoutonEnvoyer,SIGNAL(clicked()),&tra,SLOT(appaff()));
    50.         QObject::connect(&BoutonSeb,SIGNAL(clicked()),&tra,SLOT(connectionToSeb()));
    51.         QObject::connect(&BoutonJer,SIGNAL(clicked()),&tra,SLOT(connectionToJer()));
    52.         QObject::connect(&BoutonThi,SIGNAL(clicked()),&tra,SLOT(connectionToThi()));
    53.         QObject::connect(&serveur,SIGNAL(newConnection()),&son,SLOT(play()));
    54.         QObject::connect(&serveur,SIGNAL(newConnection()),&tra,SLOT(acceptClient()));
    55.     /**end*/
    56.     fenetrep.show();
    57.     return app.exec();
    58. }


    link.h
    1. #ifndef HE
    2. #include <QLabel>
    3. #include <QTextEdit>
    4. #include <QtCore\QObject>
    5. #include <QTcpServer>
    6. #include <QTcpSocket>
    7. #include <QSound>
    8. #endif
    9. using namespace std;
    10. class link : public QObject
    11. {
    12.     Q_OBJECT
    13.     public:
    14.     link(QTextEdit *T, QLabel *L,QTcpServer *S,QTcpSocket *C ) : Text(T),Label(L),Serveur(S),Client(C)
    15.      {
    16.      };
    17.     void affichage();
    18.     public slots:
    19.     void appaff();
    20.     void connectionToJer();
    21.     void connectionToSeb();
    22.     void connectionToThi();
    23.     void acceptClient();
    24.     private:
    25.     QTextEdit *Text;
    26.     QLabel *Label;
    27.     QTcpServer *Serveur;
    28.     QTcpSocket *Client;
    29. };


    link.cpp
    1. #include "link.h"
    2. void link::appaff()
    3. {
    4.     affichage();
    5. }
    6. void link::affichage()
    7. {
    8.     Label->setText(Text->toPlainText());
    9. }
    10. void link::connectionToJer()
    11. {
    12.     QSound son0("chimes.wav");
    13.     son0.play("chimes.wav");
    14.     Client->connectToHost("192.168.1.251",8282);
    15. }
    16. void link::connectionToSeb()
    17. {
    18.     QSound son0("chimes.wav");
    19.     son0.play("chimes.wav");
    20.     Client->connectToHost("192.168.1.254",8282);
    21. }
    22. void link::connectionToThi()
    23. {
    24.     QSound son0("chimes.wav");
    25.     son0.play("chimes.wav");
    26.     Client->connectToHost("192.168.1.252",8282);
    27. }
    28. void link::acceptClient()
    29. {
    30.     QTcpSocket &socket=Client;
    31.     socket=Serveur->nextPendingConnection();
    32. }


    Dans link.cpp, ligne suivante bug à la compilation mais je ne comprend pas pourquoi:
    1. socket=Serveur->nextPendingConnection();


    Pouvez vous m'aidez pour ce petit probleme?
    merci d'avance
    • Partager sur Facebook
    • Partager sur Twitter
      25 mars 2008 à 12:27:30

      salut,

      c'est quoi l'erreur ?
      et si tu faisait client = serveur->nextPendingConnection();

      a+
      hedi07
      • Partager sur Facebook
      • Partager sur Twitter

      pb de compilation a cause d'une ligne

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
      • Editeur
      • Markdown