Qt之TCP收发图片的例子-二.实现

1.发图片

void MainWindow::slotSendImage()
{
    matrix.rotate(90);
    QPixmap tempPixmap = pixmap.transformed(matrix);
    QBuffer buffer;
    tempPixmap.save(&buffer,"jpg");
    ui->labelImage->setPixmap(tempPixmap);

    int dataLength = buffer.data().size();
    QByteArray ba = buffer.data();
    tcpSocket->write(ba.data(), dataLength);
    sendImageNum++;

    ui->lineEditSendFrame->setText(QString::number(sendImageNum));
    ui->lineEditSendSize->setText(QString::number(dataLength));
}

2.收图片

connect(clientSocket, &QTcpSocket
上一篇:初学Vue(2)


下一篇:C语言+电焊