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

网站建设询价单网站推广方法

网站建设询价单,网站推广方法,公司的官方网站的作用,电脑网站建设文章目录 界面学生类序列化函数反序列化函数刷新所选择的下拉表值添加 界面 学生类 // 创建学生信息类 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.hkea.cn/news/732053/

相关文章:

  • 在凡科做网站短视频推广
  • 深圳推广公司推荐q群排名优化软件
  • 什么网站做简历模板宁德市医院
  • 用什么软件做公司网站游戏推广赚佣金的平台
  • 购物网站 后台模板河北seo技术培训
  • 聊城建设委员会官方网站google seo
  • 广西建设网郭业棚seo推广具体做什么
  • 武汉网站seo诊断谷歌下载官网
  • 做地方网站能赚钱吗免费seo网站诊断
  • 图片设计在线网站推广优化外包便宜
  • 武汉平价做网站网络软文推广案例
  • 新产品线上推广方案鞍山seo外包
  • 网站建网站建设和优佛山网络推广培训
  • 毕业设计做网站怎么样微信crm管理系统
  • 个人网站开发多少钱电脑培训班零基础
  • 互联网有哪些岗位宁波免费seo在线优化
  • 惠州做棋牌网站建设哪家技术好哪里的网络推广培训好
  • 如何做线上赌博的网站推广策略有哪些方法
  • 男的女的做那个视频网站百度收录需要多久
  • 大通县wap网站建设公司网站免费制作
  • 哪个网站教做公众号甘肃百度推广电话
  • 网站怎么让百度收录广告网络推广
  • 小型网站设计及建设论文定制网站制作公司
  • 视频网站建设费用排名优化网站seo排名
  • 怎么自己做网站服务器linux百度账号查询
  • 梧州网站推广方案百度热搜 百度指数
  • 网站不兼容ie6自助建站模板
  • 甘肃网站建设公司百中搜优化软件
  • 国内外贸网站建设公司seo教程 百度网盘
  • 一物一码二维码生成系统最好用的系统优化软件