QT图像质量双盲测试小软件的编写学习(3)

用户选择一幅质量好的图片,点击之后记录图片A1(B1)到TXT文件中,点击下一组按钮,出现下一组图,重复该过程。
设置单选控件以便用户选择左图还是右图,并设置下一组按钮以便换图、记录选择的图片和显示最后结果。

(1)设置单选控件的外形和点击后的颜色。

ui->radioButton->setStyleSheet("QRadioButton::indicator {width:15px;height:15px;border-radius:7px}""QRadioButton::indicator:checked {background-color:blue;border: 2px solid white;}""QRadioButton::indicator:unchecked {background-color:white;border: 2px solid white;}");ui->radioButton_2->setStyleSheet("QRadioButton::indicator {width:15px;height:15px;border-radius:7px}""QRadioButton::indicator:checked {background-color:blue;border: 2px solid white;}""QRadioButton::indicator:unchecked {background-color:white;border: 2px solid white;}");

(2)设置下一组按钮,实现换图、记录选择的图片。

void DisplayInterface::on_pushButton_next_clicked()
{//根据选择的图片,增加对应的计数//如果随机数是0,并且左边的单选按钮被选中,表明A文件夹里的图片被选中,记录图片名。if(randomNumber==0){if(ui->radioButton->isChecked()){ ++A_count;QFile f(dirAPath+"/"+"图片选择情况.txt");//在图像文件夹里添加txt文件f.open(QIODevice::Append);//txt文件末尾追加字符//为了记录成A1/A2/A3...QString str="A"+QString::number(current_img_index)+"/";char* ch;QByteArray ba=str.toLatin1();ch=ba.data();f.write(ch);//记录成A/// f.write("A/");f.close();}else// 如果随机数是0,而右边的单选按钮被选中,表明B文件夹里的图片被选中,记录图片名。{QFile f(dirAPath+"/"+"图片选择情况.txt");f.open(QIODevice::Append);QString str1="B"+QString::number(current_img_index)+"/";char* ch1;QByteArray ba=str1.toLatin1();ch1=ba.data();f.write(ch1);//f.write("B/");f.close();}}else if(randomNumber==1)// //如果随机数是1,并且右边的单选按钮被选中,表明A文件夹里的图片被选中,记录图片名。{if(ui->radioButton_2->isChecked()){  ++A_count;QFile f(dirAPath+"/"+"图片选择情况.txt");f.open(QIODevice::Append);QString str="A"+QString::number(current_img_index)+"/";char* ch;QByteArray ba=str.toLatin1();ch=ba.data();f.write(ch);f.close();}else// 如果随机数是1,而左边的单选按钮被选中,表明B文件夹里的图片被选中,记录图片名。{QFile f(dirAPath+"/"+"图片选择情况.txt");f.open(QIODevice::Append);QString str1="B"+QString::number(current_img_index)+"/";char* ch1;QByteArray ba=str1.toLatin1();ch1=ba.data();f.write(ch1);f.close();}}qDebug()<<"A_count:"<<A_count<<endl;QString Acount=QString::number(A_count,10);QString Totalcount=QString::number(total_image_count,10);if(current_img_index<total_image_count){show_next_image(dirAPath,dirBPath);}//否则current_img_index>=total_image_count//显示第三个界面,显示结果else if(current_img_index>=total_image_count){this->hide();QFile f(dirAPath+"/"+"图片选择情况.txt");f.open(QIODevice::Append);f.write("\r\n");f.close();emit show_resultpage(Acount, Totalcount);}}

3.和前面一样,当最后一组图片显示完毕,直接转到结果页面。
displayinterface.h中

signals:void show_resultpage(const QString&,const QString&);

resultpage.h中

private slots:void Show_Resultpage(const QString&,const QString&);

main.cpp中

QObject::connect(&displayInterface,SIGNAL(show_resultpage(const QString&,const QString&)),&resultPage,SLOT(Show_Resultpage(const QString&,const QString&)));

在这里插入图片描述
在这里插入图片描述


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部