Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unhandled exception when using QtNetwork under visual studio 2010
Forum Updated to NodeBB v4.3 + New Features

Unhandled exception when using QtNetwork under visual studio 2010

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.9k 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.
  • C Offline
    C Offline
    cerina
    wrote on last edited by
    #1

    hello,
    I created a server application under QtCreator, and it works. Now, i create a client application under Visual Studio 2010. But, when i try to connect to my server , i have an unhandled exception, and the application crashed:
    @Unhandled exception at 0x56cd6ab4 in viewer.exe: 0xC0000005: Access violation reading location 0xa1f9074d.@
    here is my code:
    @viewer::viewer(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
    {
    ui.setupUi(this);

    QObject::connect(ui.open,SIGNAL(clicked ( ) ),this,SLOT(ouvrirDialogue()));
    QTcpSocket *socket = new QTcpSocket(this);
    connect(socket, SIGNAL(readyRead()), this, SLOT(donneesRecues()));
    connect(socket, SIGNAL(connected()), this, SLOT(connecte()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(deconnecte()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erreurSocket(QAbstractSocket::SocketError)));

    // Sphere

    tailleMessage = 0;
    blockSize =0;
    }
    void viewer::on_message_returnPressed()
    {
    on_boutonEnvoyer_clicked();
    }
    void viewer::on_boutonConnexion_clicked()
    {
    ui.boutonConnexion->setEnabled(false);

    socket->abort(); // On désactive les connexions précédentes s'il y en a
    socket->connectToHost(ui.serveurIP->text(), ui.serveurPort->value()); // On se connecte au serveur demandé
    

    }
    void viewer::deconnecte()
    {
    }
    void viewer::connecte()
    {

    ui.boutonConnexion->setEnabled(true);
    

    }

    void viewer::erreurSocket(QAbstractSocket::SocketError erreur)
    {
    switch(erreur) // On affiche un message différent selon l'erreur qu'on nous indique
    {
    case QAbstractSocket::HostNotFoundError:
    QMessageBox::information(this, "connexion serveur","<em>ERREUR : le serveur n'a pas pu être trouvé. Vérifiez l'IP et le port.</em>");
    break;
    case QAbstractSocket::ConnectionRefusedError:
    QMessageBox::information(this, "connexion serveur","<em>ERREUR : le serveur a refusé la connexion. Vérifiez si le programme "serveur" a bien été lancé. Vérifiez aussi l'IP et le port.</em>");
    break;
    case QAbstractSocket::RemoteHostClosedError:
    QMessageBox::information(this, "connexion serveur","<em>ERREUR : le serveur a coupé la connexion.</em>");
    break;
    default:
    QMessageBox::information(this, "connexion serveur","<em>ERREUR : ");
    }
    }@
    Any help please and thanks

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Where is the crash in the server app or in the client app?
      Nevertheless, I am suggesting that you are running the applications in debug mode in the debugger. That should give you a glue where the problem happens.

      Vote the answer(s) that helped you to solve your issue(s)

      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