zoukankan      html  css  js  c++  java
  • Qt在使用过程中的小总结

    一、QT int转QString,并补0

    int a = 3;
    QString str = QString("%1").arg(a, 4, 10, QLatin1Char('0'));
    //str值为0003

    二、QT int转16进制,并补0

    int num = 5;
    QString res = QString("%1").arg(num,  4, 16, QLatin1Char('0'));
    //res值为0005

     三、QT之日期时间

      获取系统当前时间并设置显示格式

    QDateTime time = QDateTime::currentDateTime();
    QString currTime = time.toString("yyyy-MM-dd hh:mm::ss ddd");
    //currTime    2018-06-07 22:36::07 周四    

     四、查询字符串数据

      ① 函数QString::startsWith()判断一个字符串是否以某个字符串开头。

       此函数有两个参数:第一个参数指定了一个字符串,第二个参数指定是否大小写敏感(默认情况下是大小写敏感的)

    QString str = "Welcome to you";
    str.startWith("Welcome ", Qt::CaseSensitive);
    str.startWith("you ", Qt::CaseSensitive);

      ② 函数QString::endWith()类似于QString::startsWith(),此函数判断一个字符串是否某个字符串结尾、

      ③ 函数QString::contains()判断一个字符串是否出现过

    QString str = "Welcome to you";
    str.contains("Welcome ", Qt::CaseSensitive);//返回true
  • 相关阅读:
    jquery-卡片翻转
    bootstrap-3-验证表单
    jqeury-地区三级联动
    bootstrap-实现loading效果
    Thymeleaf-语法整理
    jquery-网站收藏
    ssh-免密登录批量发送脚本
    linux-网站收藏
    关闭防火墙
    hadoop-网站收藏
  • 原文地址:https://www.cnblogs.com/jiangson/p/9153142.html
Copyright © 2011-2022 走看看