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. Can't write in a dialog
Forum Update on Monday, May 27th 2025

Can't write in a dialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 4 Posters 2.1k Views
  • 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.
  • jsulmJ jsulm

    @hjohn It's not clear where m_clientSocket is created/comming from and where it is actually connected.

    H Offline
    H Offline
    hjohn
    wrote on last edited by hjohn
    #8

    @jsulm its in class clientMainForm : public QDialog
    As I have mentioned earlier , everything about QTcpSocket is done in clientMainForm class using signals and slots.
    in clientMainForm.h,

    public:
     QTcpSocket *m_clientSocket;
    

    clientMainForm.cpp

    void clientMainForm::on_btnConnect_clicked()
    {
        m_clientSocket=new QTcpSocket(this);
        m_clientSocket->connectToHost(ui->IPText->toPlainText(),qint16(ui->PortTxt->toPlainText().toInt()));
        if(m_clientSocket->waitForConnected(1000)){
           qDebug()<<"Client Connected";
         }
       connect(m_clientSocket,SIGNAL(readyRead()),this,SLOT(ReceiveData()));
       connect(m_clientSocket,SIGNAL(disconnected()),this,SLOT(connectionLost()));
    
    }
    
    jsulmJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #9

      Hi,

      Are you trying to implement something like Qt's network chat example ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Are you trying to implement something like Qt's network chat example ?

        H Offline
        H Offline
        hjohn
        wrote on last edited by
        #10

        @SGaist not exactly the same
        What I'm trying here is , I have a QListView in which , by using QWidget createEditor();* multiple creators(the image iploaded in earlier post) are created . I want to send the text written in that editor to server.

        1 Reply Last reply
        0
        • H hjohn

          @jsulm its in class clientMainForm : public QDialog
          As I have mentioned earlier , everything about QTcpSocket is done in clientMainForm class using signals and slots.
          in clientMainForm.h,

          public:
           QTcpSocket *m_clientSocket;
          

          clientMainForm.cpp

          void clientMainForm::on_btnConnect_clicked()
          {
              m_clientSocket=new QTcpSocket(this);
              m_clientSocket->connectToHost(ui->IPText->toPlainText(),qint16(ui->PortTxt->toPlainText().toInt()));
              if(m_clientSocket->waitForConnected(1000)){
                 qDebug()<<"Client Connected";
               }
             connect(m_clientSocket,SIGNAL(readyRead()),this,SLOT(ReceiveData()));
             connect(m_clientSocket,SIGNAL(disconnected()),this,SLOT(connectionLost()));
          
          }
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #11

          @hjohn Did you make sure that your m_clientSocket is actually connected?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          H 1 Reply Last reply
          0
          • jsulmJ jsulm

            @hjohn Did you make sure that your m_clientSocket is actually connected?

            H Offline
            H Offline
            hjohn
            wrote on last edited by
            #12

            @jsulm Yes, It's connected and working properly.
            The problem arises when I try to send message from the editor.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #13

              So you want to have several "chat windows" in your QListView that all send to the same server ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              H 1 Reply Last reply
              0
              • SGaistS SGaist

                So you want to have several "chat windows" in your QListView that all send to the same server ?

                H Offline
                H Offline
                hjohn
                wrote on last edited by
                #14

                @SGaist Yes.
                I have a QListView and QWidgetcreateEditor()* has put those chat windows in that ListView.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #15

                  And each of these chat window would handle its socket itself ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  H 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    And each of these chat window would handle its socket itself ?

                    H Offline
                    H Offline
                    hjohn
                    wrote on last edited by
                    #16

                    @SGaist yes probably
                    the widget should recognize the socket .

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #17

                      Then it looks like the Fortune Client example might be a better base.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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