当前位置:网站首页>Qt Notes - qmap Custom key
Qt Notes - qmap Custom key
2022-06-22 16:58:00 【It1995】
Comme suitkeyValeur:
struct MyKey{
MyKey(QString key1, int key2){
this->key1 = key1;
this->key2 = key2;
}
QString key1;
int key2;
};PersonnalisationkeyLes problèmes suivants se posent:

Le symbole d'action gauche doit être dépassé,Comme suit:
struct MyKey{
MyKey(QString key1, int key2){
this->key1 = key1;
this->key2 = key2;
}
bool operator < (const MyKey &key) const{
return std::tie(key1, key2) < std::tie(key.key1, key.key2);
}
QString key1;
int key2;
};Toutes les sources sont les suivantes::
#include <QCoreApplication>
#include <QMap>
#include <QDebug>
struct MyKey{
MyKey(QString key1, int key2){
this->key1 = key1;
this->key2 = key2;
}
bool operator < (const MyKey &key) const{
return std::tie(key1, key2) < std::tie(key.key1, key.key2);
}
QString key1;
int key2;
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QMap<MyKey, QString> map;
map.insert(MyKey("10086", 0), "value1");
map.insert(MyKey("10086", 1), "value2");
map.insert(MyKey("10086", 2), "value3");
map.insert(MyKey("10010", 1), "value4");
map.insert(MyKey("10010", 2), "value5");
return a.exec();
}
Voici une capture d'écran de débogage:

Code source package download address:
边栏推荐
- Summary of spark common operators
- 系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式
- Spark's NaiveBayes Chinese text classification
- 启牛学堂给的中信建投证券账户是不是真的?开户安全吗
- Test for API
- 迭代器与生成器
- The world's "first" IEEE privacy computing "connectivity" international standard led by insight technology was officially launched
- Spark streaming receiver startup and data receiving
- Redis实现延迟队列的正确姿势
- 交互电子白板有哪些特点?电子白板功能介绍
猜你喜欢
![[deep anatomy of C language] keywords if & else & bool type](/img/cf/a0533b7d3a597368aefe6ce7fd6dbb.png)
[deep anatomy of C language] keywords if & else & bool type

VHEDT业务发展框架

系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式

每秒处理10万高并发订单的乐视集团支付系统架构分享

IDEA安装总结

How to add a "security lock" to the mobile office of government and enterprises?

Figure operation flow of HAMA BSP Model

System throughput, TPS (QPS), user concurrency, performance test concepts and formulas
数据库mysql 主从方案

High availability ResourceManager
随机推荐
MYSQL_ERRNO : 1292 Truncated incorrect date value At add_num :1
Interface (optimization type annotation)
Mysql-5.6.21-centos6.5 source code installation configuration
接口(优化类型注解)
联合主键引发的思考
Spark streaming receiver startup and data receiving
2022年中国重卡智能化升级专题研究
mysql账号增删改、数据导入导出命令举例
[MYSQL]一台windows电脑安装多个mysql-不同版本
交互电子白板有哪些特点?电子白板功能介绍
Jsp Learning (2) - - jsp script Elements and instructions
spark常用 算子小总结
Bidirectional data binding V-model and v-decorator
系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式
What should I do if I can't hear a sound during a video conference?
Spark on data skew
How to open an account in flush? Is it safe to open an account online?
洞见科技牵头的全球「首个」IEEE隐私计算「互联互通」国际标准正式启动
Spark Streaming checkpoint的问题与恢复
迭代器与生成器
https://github.com/fengfanchen/Qt/tree/master/QMapKeyCustom