1.QT该容器QVector,QList,QSet,QMap,QQueue,QStack,QMultiMap,QSingleList等待
1
新建一个项目
在pro文件里仅仅须要加上CONFIG |
main.cpp |
#include int { QMap<int,QString> map.insert(1,"1"); map.insert(2,"2"); map.insert(3,"3"); map[4] if(map.find(1) { //not } /* * * * * */ foreach(int { QString qDebug() } for(auto { it.key(); it.value(); #if if(needRemove) { it } else { ++i; } #endif } map.remove(1); } |
执行结果: |
#include <QVector> #include <QList> #include <QMap> #include <QSet> #include <QQueue> #include <QStack> #include <QMultiMap> #include <QDebug> #include <QStringList> int main() { QVector<int> intVector; intVector << 5; intVector.append(15); intVector.push_front(10); intVector.push_back(20); foreach(int value, intVector) { qDebug() << value; } QVector<int>::iterator it; for(it = intVector.begin(); it!=intVector.end(); ++it) { qDebug() << *it; } int size = intVector.size(); for(int i = 0; i < size; ++i) { qDebug() << intVector[i]; qDebug() << intVector.at(i); } //查找 qDebug() << intVector.indexOf(5); //sort qSort(intVector); //删除一个 //intVector.removeOne(5); //intVector.removeAll(5); qDebug() << "sort"; for(it = intVector.begin(); it!=intVector.end(); ++it) { qDebug() << *it; } } |
执行结果: |
版权声明:本文博客原创文章,博客,未经同意,不得转载。
1.QT该容器QVector,QList,QSet,QMap,QQueue,QStack,QMultiMap,QSingleList等待的更多相关文章
- 1.QT中的容器QVector,QList,QSet,QMap,QQueue,QStack,QMultiMap,QSingleList等
1 新建一个项目 在pro文件中只需要加上CONFIG += C++11 main.cpp #include <QMap> int main() { QMap<int,QStrin ...
- Qt 使用qDebug() 打印Qlist 容器数据(将QDebug()定义成某个类的友元函数)
当QList<T>容器中的数据用qDebug() 打印时 ,假如 T 是内置类型(int float ...)与 打印一个字符串使用完全一样,假如T 是一个CustomerClass 那 ...
- Qt无法调试Qvector
现象: 解决: 打开文件 $(VSDIR)\Common7\Packages\Debugger\autoexp.dat (VSDIR是本机Visual Studio的安装目录)把定义QVector和Q ...
- Qt: 访问容器(三种方法,加上for循环就四种了)good
#include <iostream>#include <QString>#include <QList>#include <QListIterator> ...
- Qt 之容器内的控件全屏
m_label = new QLabel(); ui->stackedWidget->addWidget(m_label); ui->stackedWidget->setCur ...
- qt 访问容器
#include <iostream> #include <QString> #include <QList> #include <QListIterator ...
- Qt 使用QLabel、QMovie加载gif图片实现动态等待窗口
新建基于Widget的应用程序,在ui的窗口中添加QLabel,对象名label,调整整个窗口大小. 准备loading.gif图片 Widget.cpp 12345678910111213141 ...
- Qt5 编程基础
Qt 是一个C++ GUI应用框架,Qt 具有良好的可移植性支持大多数桌面和移动操作系统并常用于嵌入式开发. Qt的发行版分为商业版和开源版,提供了Qt Creator作为轻量级IDE. Hello ...
- Qt中QVector与QList的应用
首先來看看QVector 的基本使用方式,建立一個可容納兩個元素的QVector ,並使用索引方式存取元素值:QVector<double> vect(2); vect[0] = 1.0; ...
随机推荐
- POJ 1258 Agri-Net|| POJ 2485 Highways MST
POJ 1258 Agri-Net http://poj.org/problem?id=1258 水题. 题目就是让你求MST,连矩阵都给你了. prim版 #include<cstdio> ...
- [Recompose] Transform Props using Recompose --mapProps
Learn how to use the 'mapProps' higher-order component to modify an existing component’s API (its pr ...
- [Webpack] Configure Prepack with Webpack
Great improvements and optimizations can be made to the output of bundled code. Prepack provides the ...
- solr源码导入eclipse 分类: H4_SOLR/LUCENCE 2014-07-14 14:11 550人阅读 评论(1) 收藏
转载自:http://blog.csdn.net/vltic/article/details/19917377 (1)相应的开发环境准备 (1)jdk1.6+的安装和环境变量配置(命 ...
- Multi-Tenancy模式,基础服务大规模扩张的时候,是应该推进了。
这不是技术介绍.这是我要推进的工作,记在这里.服务的对象太多,必须隔离为不同租户了.
- java判断字符串是否为数字
我们在做安卓开发中,一定会遇到判断某字符串是否是数字的问题,本文使用正则表达式可以很方便的判断出来,希望本文对安卓开发者有所帮助. 1 public boolean isNumeric(Strin ...
- Android 设置图片 Bitmap任意透明度
两种思路,第一种思路是通过对Bitmap进行操作,将Bitmap的像素值get到一个int[]数组里,因为在android里Bitmap通常是ARGB8888格式,所以最高位就是A通道的值,对齐进行改 ...
- 云平台DevOps实践
基于TFS的.net技术路线的云平台DevOps实践 DevOps是近几年非常流行的系统研发管理模式,很多公司都或多或少在践行DevOps.那么,今天就说说特来电云平台在DevOps方面的实践吧. ...
- 使用SecureCRT连接AWS的EC2
如果使用CentOS等linux系统,直接使用ssh命令即可访问AWS上的Linux-EC2实例. $ ssh -i XXX.pem ec2-user@{IP/hostname} 在Windows系统 ...
- Filter,Listener(转)
一.Filter的功能filter功能,它使用户可以改变一个 request和修改一个response. Filter 不是一个servlet,它不能产生一个response,它能够在一个reques ...