这几天在上嵌入式课程设计,需要用到Qt,这个是信号与槽的,寒假的时候也简单学习了一些,但是没有怎么深入,又回过来看了看Qt,发现Qt的ui界面配置与Android的好像,当然Qt也可以拿来开发Android。

废话不多说了,直接上代码:

用正则表达式提取数据

void testRegexCapture()
{
QString pattern(“(.*)=(.*)”);
QRegExp rx(pattern); QString str(“a=″);
int pos = str.indexOf(rx); // 0, position of the first match.
// Returns -1 if str is not found.
// You can also use rx.indexIn(str);
qDebug() << pos;
if ( pos >= )
{
qDebug() << rx.matchedLength(); // 5, length of the last matched string
// or -1 if there was no match
qDebug() << rx.capturedTexts(); // QStringList(“a=100″, ”a”, ”100″),
// 0: text matching pattern
// 1: text captured by the 1st ()
// 2: text captured by the 2nd () qDebug() << rx.cap(); // a=100, text matching pattern
qDebug() << rx.cap(); // a, text captured by the nth ()
qDebug() << rx.cap(); // 100, qDebug() << rx.pos(); // 0, position of the nth captured text
qDebug() << rx.pos(); //
qDebug() << rx.pos(); //
}
}

用正则表达式修改文本

QString s = ”a=″;
s.replace(QRegExp(“(.*)=”), ”b=”);
qDebug() << s; // b=100
QString s = ”a=″;
s.replace(QRegExp(“(.*)=(.*)”), ”\\\\=\\″); // \1 is rx.cap(1), \2 is rx.cap(2)
qDebug() << s; // a100=100

用正则表达式验证文本有效性

void testRegexMatch()
{
QString pattern(“.*=.*”);
QRegExp rx(pattern); bool match = rx.exactMatch(“a=″);
qDebug() << match; // True match = rx.exactMatch(“a/″);
qDebug() << match; // False
}

我是天王盖地虎的分割线                                                                   

当初了解到Qt是在学习MFC的时候,当时写MFC程序才叫伤心啊。

Qt一次编写,多次编译。在windows还是linux平台上,只需要换一下编译器就OK,代码都不需要怎么改的。

通过写linux上的程序,我涉及到的这个程序是arm板子上,通过串口通信读取zigbee发来的信息。主要是板子上驱动写的好,Qt写个串口通信就可以直接拿来用。

转载请注明出处:http://www.cnblogs.com/yydcdut

最新文章

  1. ecshop二次开发 给商品添加自定义字段【包含我自己进一步的开发实例详解】
  2. 15 cvpr An Improved Deep Learning Architecture for Person Re-Identification
  3. Registry values for ProductID and LocaleID for AutoCAD and the vertical products
  4. 判断表字段是否存在default约束
  5. RequireJS学习资料汇总
  6. 启用域中对象的&quot;防止意外删除&quot;功能
  7. link them together by means of pointers
  8. wince下的CPU和内存占用率计算
  9. c# listview导出excel文件
  10. Codevs 4189 字典
  11. 《Windows驱动开发技术详解》之派遣函数
  12. AngularJS进阶(二十二)实现时间选择插件
  13. vue_v-for_遍历数组_遍历对象
  14. Elastic-Job-分布式调度解决方案
  15. thymeleaf:日常使用总结
  16. attr 和 prop 的区别
  17. Swift5 语言指南(十八) 可选链接
  18. SeaweedFS上手使用指南
  19. 深入理解nodejs的next函数。koa的使用 app.params的使用
  20. form提交不刷新,不跳转页面

热门文章

  1. 20169211《Linux内核原理与分析》第四周作业
  2. Mutex 的正确打开方式
  3. FileBuffer-ImageBuffer 模拟PE
  4. C# 找出实现某个接口的所有类
  5. .net中session的使用
  6. JZYZOJ1622 [usaco2009]工作安排 贪心
  7. 【裸裸的左偏树】BZOJ1455-罗马游戏
  8. 去除List中的重复元素
  9. 【转】_CrtSetBreakAlloc 内存泄漏
  10. python开发_filecmp