20191014

第五章   model/view

组件显示/编辑数据的一种结构
QListView QTreeView QTableView
预定义数据模型

QAbsstracItemModel类

QStringListModel   
QStandardItemModel  数据项
QFileSystemModel   
QSortFilterProxyModel  排序过滤
QSqlQueryModel  
QSqlTableModel  表
QSqRelationalTableModel

QModelIndex模型索引的类
持久性模型索引: QPersistentModelIndex

获取索引的三个参数: 行号,列号,父项

项的角色:
void QStandItem::setData(const QVariant &value,int role = Qt::UserRole++1);

QFileSystemModel *model = new QFileSystemModel;
model->setRootPath(QDir::currentPath());

1 创建一个模型,在视图中添加模型
2 接受下表判断是否合法。

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    themodel = new QStringListModel(this);
    QStringList theStrlist;
    theStrlist<<"北京"<<"上海"<<"合肥";
    themodel->setStringList(theStrlist);
    ui->listView->setModel(themodel);
   // ui->listView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);  //设置可以编辑状态
    ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_addpushButton_clicked()
{
    themodel->insertRow(themodel->rowCount());
    QModelIndex index = themodel->index(themodel->rowCount()-1,0);
    themodel->setData(index,"new item",Qt::DisplayRole);
    ui->listView->setCurrentIndex(index);
}

void MainWindow::on_editpushButton_2_clicked()
{
    QModelIndex index = ui->listView->currentIndex();
    themodel->insertRow(index.row());
    themodel->setData(index,"insert item",Qt::DisplayRole);
   // ui->listView-setCurrentIndex(index);
    ui->listView->setCurrentIndex(index);
}

void MainWindow::on_pushButton_3_clicked()
{
    QModelIndex index = ui->listView->currentIndex();
    themodel->removeRow(index.row());

}

void MainWindow::on_pushButton_clicked()
{
    themodel->removeRows(0,themodel->rowCount());
}

void MainWindow::on_pushButton_2_clicked()
{
    QStringList tmpList = themodel->stringList();
    ui->plainTextEdit->clear();
    for(int i=0;i<tmpList.count();i++)
    {
        ui->plainTextEdit->appendPlainText(tmpList.at(i));
    }
}

void MainWindow::on_listView_clicked(const QModelIndex &index)
{
    ui->label->setText(QString::asprintf("当前条目:row= %d,column = %d",index.row(),index.column()));
}

QStandardItemModel
QTableView
QItemSelectionModel

利用Curl向服务器发送请求:

1 封装数据
2 设置curl
3 开启psot请求
3 添加数据
4 设定回调函数
5 给回调函数一个参数
6 等待回复
7 处理响应
8 定义一个结构体,接受回复数据

Andriod studio app中:
第一步:
定义一个JNI接口类,实现单例模式。
注册接口: public native boolean reg(String username, String passwd,String )
第二步:
进入项目文件,进入java, javah -jni  file 生成头文件
第三步:
添加.cpp文件
添加头文件
//防止变量名改变
extern "c"
{
 java方法转化为c
 把java数据转化为c数据
 const char *usrname = env->GetStringUFTChars(j_name,NULL);
 封装JSON数据:
 打印日志。
 添加curl类,创建curl对象。执行向后台发送数据。
 接受后台数据。
 解析后台数据。

释放资源
 env->ReleaseStringUTFChars()

}
第四步 创建Json类
void insert(string key,string value);
string print();
防止json进行拷贝,出现浅拷贝风险。  把拷贝函数和operator= 私用
让jni支持stl 和c++11
在Application.mk添加
APP_STL := stlport_static
APP_CFLAGS := -std=c++11

匿名拷贝。先创建一个对象。用一个变量名接受。

第五步  powershell 进入JNI文件夹 ndk build

第六步  封装curl类
方法: 发送数据
成员函数含有this指针,去掉this指针的方法是加上static

copy(p,p+count,back_inserter(char *str));
尝试在str的尾部添加

https  采用opnssl加密
服务器公钥 服务器私钥   合法的CA证书

第一步
客户端  尝试连接   HTTPS服务器
第二步
HTTPS服务器   返回证书(服务器公钥,证书) 客户端
客户端辨别CA证书的合法性,生成一对客户端的公钥,客户端的私钥
第三步
用服务器的公钥加密客户端的公钥和客户端的密钥
用服务器的私钥解密得到客户端的公钥
第四步
用客户端的公钥生成一个与客户端的会话公钥
第五步:
客户端加密数据请求服务器
第六步:
用服务器的加密会话通信。

https 加密过程
第一步: 非对称加密认证数据
第二部: 对称加密  加密算法openssl算法

安装openssl

demo写好的,在里面写callback.

两个服务器:数据和业务。
客户端: jni通信。 
通信协议: /loggin json
    /reg json
    /order

服务器间通信web与存储通信协议:
/persistent json
/cache

1 持久数据库 用户信息
cmd:
busi:
tale:
字段:
用户表,接单表。

2 缓存数据库
HASH类型数据。
redis.cn
设置key,获取key

vsp:sp

grep name . -r --color  查询文件夹中包含字符串“name”的文件

数据服务器:
封装一个CJSON数据。
表明。

QSGContext::initialize: depth buffer support missing,expert rendering errors

注册回调函数:
定义结构体,接受数据。
定义一个curl 指针。
1 设置curl的路径。
2 设置忽略openssl CA认真
3 设置curl为post类型
4 设置curl的数据
5 设置回调函数
6 设置形参

提交请求向data服务器
curl_easy_perform(curl)

util.h
公共函数

git修改代码:
第一步:
git status
第二步:
git pull 更新本地代码
第三步:
git commit file.c -m"日志"
第四部步:
git push -u origin master
添加:
git add main.c 到本地版本控
git commit main.c -m"原因"
git pull 
git push -u origin master

回退版本:
git stash
git pull
git stash pop

解决冲突:
git pull

原文地址:https://www.cnblogs.com/countryboy666/p/11675275.html

时间: 2024-08-29 01:12:06

20191014的相关文章

2019年工作日

2019010220190103201901042019010720190108201901092019011020190111201901142019011520190116201901172019011820190121201901222019012320190124201901252019012820190129201901302019013120190201201902112019021220190213201902142019021520190218201902192019022020

AES加密解密,自定义加密规则记录

package com.jx.utlis; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Scanner; impor

Tensorflow中保存模型时生成的各种文件区别和作用

假如我们得到了如下的checkpoints, 上面的文件主要可以分成三类:一种是在保存模型时生成的文件,一种是我们在使用tensorboard时生成的文件,还有一种就是plugins这个文件夹,这个是使用capture tpuprofile工具生成的,该工具可以跟踪TPU的计算过程,并对你的模型性能进行分析,这里就不想详细介绍了.本文主要介绍前面两种文件的作用: tensorboard文件 events.out.tfevents.*...: 保存的就是你的accuracy或者loss在不同时刻的

Linux_基础优化

01.添加普通用户 命令:useradd 设置用户密码: -交互方式:passwd oldbpoy -免交互方式:echo 123456|passwd -stdin oldboy 切换用户信息: su -root :切换为root需要密码 su -oldboy :切换为普通用户不需要密码 用户信息查看 : whoami [[email protected] oldboy]# whoami root [[email protected] oldboy]# who a mi root pts/0 2

RK 平台 MIPI 点屏注意事项

2019-10-14 关键字:rk3288 MIPI 点屏 rk 平台关于 MIPI 屏幕的点屏流程已经非常完善了,基本上只要确定了硬件没问题.接线没问题.屏幕没问题,再稍稍配置一下 dtsi 里的参数就可以的了. MIPI 点屏流程大致可以概括为以下几步: 1.确认硬件环境: 2.确认相关接口管脚: 3.配置屏幕背光 dts: 4.配置 MIPI 屏幕参数: 5.屏幕显示效果调校. 1.确认硬件环境 确认硬件环境这个活理论上来说是由硬件人员来提供保证的,大多数软件人员都不懂这块的知识,只能相信

SQL-连接查询:left join,right join,inner join,full join之间的区别

参考: https://www.cnblogs.com/lijingran/p/9001302.html https://www.cnblogs.com/assasion/p/7768931.html 因为单纯的select * from a,b是笛卡尔乘积.比如a表有5条数据,b表有3条数据,那么最后的结果有5*3=15条数据. 所以需要对两个表进行关联: select * from a,b where a.id = b.id 此时就等价于: select * from a inner joi

由最多N个给定数字集组成的数字 Numbers At Most N Given Digit Set

2019-10-14 22:21:29 问题描述: 问题求解: 暴力求解必然会超时,那么就需要考虑数学的方法来降低时间复杂度了. public int atMostNGivenDigitSet(String[] D, int N) { int n = D.length; int res = 0; char[] chs = new char[n]; for (int i = 0; i < n; i++) { chs[i] = D[i].charAt(0); } char[] nums = Stri

Linux 下的 UDP 编程

2019-10-14 关键字:C 语言的 UDP 编程与实例 UDP 连接是一种无连接的网络连接协议. Linux 下的 UDP 编程的函数接口与 TCP 差不了多远.在 UDP 通信模型中,也是以 C/S 模型来通信的. 服务端的函数调用流程主要有以下几个: 1.socket() 2.bind() 3.recvfrom() / sendto() 4.close() 客户端的函数调用流程主要有以下几个: 1.socket() 2.sendto() / recvfrom() 3.close() s

Shiro身份认证、盐加密

目的: Shiro认证 盐加密工具类 Shiro认证 1.导入pom依赖 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.apache.s