|
5Qter豆
void Client::startTransfer() //发送信息{ localFile = new QFile(fileName); if(! localFile->open(QFile::ReadOnly)) { qDebug() << "clientpen file error!"; return; } totalBytes = localFile->size(); //获取文件大小
QDataStream sendOut(&outBlock,QIODevice::WriteOnly); sendOut.setVersion(QDataStream::Qt_4_0); QString currentFileName = fileName.right(fileName.size() - fileName.lastIndexOf('/') - 1);//倒着数,计算位置 sendOut << qint64(0) << qint64(0) << currentFileName; totalBytes += outBlock.size(); sendOut.device()->seek(0); sendOut << totalBytes << qint64((outBlock.size() - sizeof(qint64)*2)); //添加大小信息 bytesToWrite = totalBytes - tcpClient->write(outBlock); //文件内容的大小////////////////这里的outblock具体内容是什么,多大,为什么我运行时下面这句显示为空,,,,,,(后面传输时感觉都不到64k,它不等于sendout吗????????)
qDebug() << tr("outBlockfirst:") << outBlock;
ui->clientStatusLable->setText(tr("已连接")); outBlock.resize(0); //清零
}
|
最佳答案
查看完整内容
totalBytes是总的大小,你说的那个实际大写是指文件大小吗,它应该是localFile->size()。
|