安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
voidWidget::onDownloadProgress(qint64bytesReceived,qint64bytesTotal) {
if(bytesTotal>0) {
intvalue=(bytesReceived*100)/bytesTotal; m_progress->setValue(value); } }
voidWidget::onUploadProgress(qint64bytesSent,qint64bytesTotal) {
if(bytesTotal>0) {
intvalue=(bytesSent*100)/bytesTotal; m_progress->setValue(value); } }
voidWidget::onReadyRead() {
QByteArraydata=m_reply->readAll();
m_stateText->append(QString(\).arg(data.length())); if(m_file) {
m_file->write(data); } }
voidWidget::onFinished() {
QStringstrState=m_reply->error()==QNetworkReply::NoError?\\:m_reply->errorString();
m_stateText->append(QString(\) .arg(strState));
m_stateText->append(\); resetState(); }
voidWidget::resetState() {
if(m_file) {
m_file->close();
第33页共61页
面向对象程序设计:实验报告
安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
deletem_file; m_file=0; }
if(m_request) {
deletem_request; m_request=0; }
if(m_reply) {
m_reply->disconnect(this); m_reply->deleteLater(); m_reply=0; }
enableControls(); }
boolWidget::openFile(boolsave,QString&errorString) {
if(m_strFilePath.isEmpty()) {
errorString=\; returnfalse; }
if(m_file) {
deletem_file; m_file=0; }
m_file=newQFile(m_strFilePath);
if(!m_file->open(save?QFile::WriteOnly:QFile::ReadOnly)) {
errorString=m_file->errorString(); deletem_file; m_file=0; returnfalse; }
returntrue; }
第34页共61页
面向对象程序设计:实验报告
安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
六、实验结果与分析
第35页共61页
面向对象程序设计:实验报告
安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
第36页共61页
面向对象程序设计:实验报告
安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
七、教师评价
第37页共61页
面向对象程序设计:实验报告