16,815
社区成员




//! 4.2.1、发送文件
void mainWidget::on_toolButton_16_clicked()
{
tcpClient->disconnectFromHost(); //断开连接
//tcpClient->waitForDisconnected(); //保证上次所发送文件完整
sendFileIndex = ui->listView_5->currentIndex();
sendFileName = filemodel->fileInfo(sendFileIndex).fileName();
sendFilePath = filemodel->fileInfo(sendFileIndex).absoluteFilePath(); //获取带路径的文件名
bytesWritten = 0; //初始化已发送字节为0
ui->clientStatusLabel->setText(tr("Connecting…"));
tcpClient->connectToHost(QHostAddress(ui->hostLineEdit->text()),ui->portLineEdit->text().toInt());//连接
}
//tcpPort = 6666;
while(!tcpServer.listen(QHostAddress("192.168.10.211"),ui->portLineEdit->text().toInt()))
{
qDebug() << tcpServer.errorString();
return;
}
ui->serverStatusLabel->setText(tr("Listening监听"));