安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\
,\,\
,\,\ ,\,\ ,\,\
,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\
,\,\
,\,\ ,\,\ ,\,\
,\,\ ,\,\
第23页共61页
面向对象程序设计:实验报告
安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
,\,\
,\,\
,\,\ ,\,\
,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\
第24页共61页
面向对象程序设计:实验报告
安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
,\,\
,\,\
,\,\ ,\,\
,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\ ,\,\
,\,\ ,\,\ ,\,\ };
staticconstchar*_get_content_type(char*filename) {
inti=0;
intsize=sizeof(g_ext_to_content_type)/sizeof(g_ext_to_content_type[0]);
char*ext=filename;
char*slash=strrchr(filename,'/'); if(slash) {
slash++; } else {
slash=filename; }
ext=strrchr(filename,'.'); if(!ext) {
return\;
第25页共61页
面向对象程序设计:实验报告
安庆师范学院计算机与信息学院
Anqing teacher school College of computer and information
}
for(;i if(!strcmp(ext,g_ext_to_content_type[i])) { returng_ext_to_content_type[i+1]; } } return\; } Widget::Widget(QWidget*parent) :QWidget(parent) ,m_nam(this) ,m_reply(0) ,m_request(0) ,m_file(0) { setupGUI(); } Widget::~Widget() { if(m_file) { m_file->close(); deletem_file; } if(m_reply) { m_reply->disconnect(this); m_reply->abort(); deletem_reply; } } voidWidget::setupGUI() { QVBoxLayout*mainLayout=newQVBoxLayout(); setLayout(mainLayout); 第26页共61页 面向对象程序设计:实验报告 安庆师范学院计算机与信息学院 Anqing teacher school College of computer and information m_headerValueGroup=newQGroupBox(tr(\),this); QGridLayout*headerValueLayout=newQGridLayout(); headerValueLayout->setColumnStretch(1,1); m_headerValueLabel=newQLabel(tr(\),this); m_headerValueEdit=newQLineEdit(this); m_headerKeyLabel=newQLabel(tr(\),this); m_headerKeyEdit=newQLineEdit(this); m_addHttpHeaderValueButton=newQPushButton(tr(\),this); connect(m_addHttpHeaderValueButton,SIGNAL(clicked()),this,SLOT(onAddHttpHeaderValue())); headerValueLayout->addWidget(m_headerKeyLabel,0,0,Qt::AlignRight|Qt::AlignVCenter); headerValueLayout->addWidget(m_headerKeyEdit,0,1); headerValueLayout->addWidget(m_headerValueLabel,1,0,Qt::AlignRight|Qt::AlignVCenter); headerValueLayout->addWidget(m_headerValueEdit,1,1); headerValueLayout->addWidget(m_addHttpHeaderValueButton,2,0,1,2,Qt::AlignRight|Qt::AlignVCenter); m_headerValueGroup->setLayout(headerValueLayout); mainLayout->addWidget(m_headerValueGroup); m_paramGroup=newQGroupBox(tr(\),this); QGridLayout*paramLayout=newQGridLayout(); paramLayout->setColumnStretch(1,1); m_urlLabel=newQLabel(tr(\),this); m_urlEdit=newQLineEdit(this); m_methodLabel=newQLabel(tr(\),this); m_methodCombo=newQComboBox(this); m_methodCombo->setEditable(false); m_methodCombo->addItem(\); m_methodCombo->addItem(\); m_methodCombo->addItem(\); m_methodCombo->addItem(\); //m_methodCombo->setCurrentIndex(0); connect(m_methodCombo,SIGNAL(currentTextChanged(QString)) ,this,SLOT(onMethodChanged(QString))); m_startButton=newQPushButton(tr(\),this); connect(m_startButton,SIGNAL(clicked()),this,SLOT(onStart())); paramLayout->addWidget(m_urlLabel,0,0,Qt::AlignRight|Qt::AlignVCenter); paramLayout->addWidget(m_urlEdit,0,1); 第27页共61页 面向对象程序设计:实验报告