Can't write in a dialog
-
@hjohn It's not clear where m_clientSocket is created/comming from and where it is actually connected.
@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())); }
-
Hi,
Are you trying to implement something like Qt's network chat example ?
-
Hi,
Are you trying to implement something like Qt's network chat example ?
-
@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())); }
-
So you want to have several "chat windows" in your QListView that all send to the same server ?
-
So you want to have several "chat windows" in your QListView that all send to the same server ?
-
And each of these chat window would handle its socket itself ?
-
Then it looks like the Fortune Client example might be a better base.