当前位置: 首页 > news >正文

网站开发最新书籍市场调研的四个步骤

网站开发最新书籍,市场调研的四个步骤,wordpress后台添加logo,上海做网站的文章目录 界面学生类序列化函数反序列化函数刷新所选择的下拉表值添加 界面 学生类 // 创建学生信息类 class studentInfo { public:QString id; // 学号QString name; // 学生姓名QString age; // 学生年龄// 重写QDataStream& operator<<操作符&…

文章目录

  • 界面
  • 学生类
  • 序列化函数
  • 反序列化函数
  • 刷新所选择的下拉表值
  • 添加

在这里插入图片描述

界面

在这里插入图片描述

学生类

// 创建学生信息类
class studentInfo
{
public:QString id;     // 学号QString name;   // 学生姓名QString age;        // 学生年龄// 重写QDataStream& operator<<操作符,做数据序列化操作friend QDataStream& operator<<(QDataStream &stream, const studentInfo &student){// 将数据输入流对象中stream << student.id;stream << student.name;stream << student.age;return stream;}// 重写QDataStream& operator>>操作符,做数据反序列化操作friend QDataStream& operator>>(QDataStream &stream, studentInfo &student){// 从流对象中输出数据到学生结构体引用中stream >> student.id;stream >> student.name;stream >> student.age;return stream;}
};

序列化函数

将其放入容器内方便便利每一个学生参数的值

 QList<studentInfo> list;studentInfo student;

获取文本编辑的值读取到序列化文件中进行保存

//保存
void MainWindow::on_pushButton_clicked()
{studentInfo student;//序列化为二进制文件存在本地QFile file(QApplication::applicationDirPath()+"/"+"student.st");           //定义文件路径file.open(QIODevice::WriteOnly); //以只写模式打开QDataStream out(&file);          //定义数据流student.id=ui->m_Id->text();student.age=ui->m_Age->text();student.name=ui->m_Name->text();list.append(student);out<<list;qDebug()<<list[0].id;file.close();qDebug()<<(QString("OK"));ReShowCombox();
}

刷新下拉表的值

void MainWindow::ReShowCombox()
{// 获取 studentInfo 对象if(list.size()>0){ui->comboBox->addItem(list.last().name);}
}

反序列化函数

读取文件的值,添加到下拉列表中

void MainWindow::GetFile()
{studentInfo student;//反序列化本地二进制文件到程序中QFile file(QApplication::applicationDirPath()+"/"+"student.st");//文件在程序运行目录下if(file.exists())//如果文件存在,则从文件读取数据{file.open(QIODevice::ReadOnly);QDataStream in(&file);in>>list;file.close();}// 获取 studentInfo 对象if(list.size()>0){student.id=list.at(0).id;student.age=list.at(0).age;student.name=list.at(0).name;ui->m_Id->setText(student.id);ui->m_Age->setText(student.age);ui->m_Name->setText(student.name);for(int i=0;i<list.size();i++){ui->comboBox->addItem(list.at(i).name);}}}

刷新所选择的下拉表值

连接信号与槽函数

 connect(ui->comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::on_comboBox_currentIndexChanged);

获取到当前的值

void MainWindow::on_comboBox_currentIndexChanged(int index)
{if (index >= 0) {// 获取当前选中项的 studentInfo 对象studentInfo student = list.at(index);// 刷新其他控件的值ui->m_Id->setText(student.id);ui->m_Name->setText(student.name);ui->m_Age->setText(student.age);}
}

添加

void MainWindow::on_pushButton_2_clicked()
{ui->m_Id->setText("");ui->m_Name->setText("");ui->m_Age->setText("");}
http://www.dt0577.cn/news/27489.html

相关文章:

  • 建设工程信息哪个网站有详细信息百度软件下载安装
  • 医疗网站女性专题网页设计模板seo基础入门
  • 乡村别墅室内装修设计效果图关键词优化一般收费价格
  • 情感营销案例优化营商环境 提升服务效能
  • 网站建设公司业务寻找外贸客户的网站
  • dede网站入侵教程有创意的营销案例
  • 网站做强制访问控制seo超级外链工具
  • 一级域名免费网站怎么申请公司官网优化方案
  • 建站公司最新排名松松软文平台
  • 网站建设中 html5中山网站seo优化
  • 石油大学 网页设计与网站建设2021友情链接qq群
  • 免费做暧暧网站俄罗斯搜索引擎浏览器官网入口
  • 服务器租用网站自动划分空间专业的google推广公司
  • 做招聘的网站有哪些seowhy官网
  • 用什么软件来建网站百度广告怎么收费标准
  • 注册外贸公司需要多少钱seo是怎么优化上去
  • 购物网站销售管理淘宝排名查询
  • 江门官网建站公司2345网址导航电脑版
  • 公司网站规划案例百度一下照片识别
  • 卓商网站建设公司百度推广开户
  • 网站使用支付接口如何收费产品宣传推广策划
  • 上海建站 seo免费下载百度seo
  • 公司内部自己做抽奖网站上海百度研发中心
  • 做装修网站如何播放量自助下单平台
  • 一个人做网站好做吗域名官网
  • python做网站缺点fba欧美专线
  • 网站建设外包必须注意几点chrome手机版
  • 做信息流推广需要建立网站么营销型网站建设ppt
  • 淄博市住房城乡建设局政府网站河北seo公司
  • jsp动态网站开发课程电商运营seo