Qt和树莓派中重复率高的代码

一:延时等待函数

1,所需头文件 

#include <QEventLoop>

#include <QTime> 

2,源代码

QEventLoop eventLoop;    //定义一个事件循环

QTimer::singleShot(500,&eventLoop,SLOT(quit()));  //定时500ms,触发事件退出信号
eventLoop.exec();    //事件循环开始运行

注:此循环函数运行时,依然可以响应用户的事件

二:得到按钮发送者的指针

QPushButton *s=dynamic_cast<QPushButton *>(this->sender());

三:根据月份和日期动态创建密码

单行文本框设置密码模式:ui->passwordLineEdit->setEchoMode(QLineEdit::Normal);

dynamicCreatePassword()
{
     QDate date=QDate::currentDate();
     int i=0;
     QString temp;
     temp.clear();
     qsrand(date.year()%100+date.month());
     for(i=0;i<8;i++)
     {
     temp.append(QString::number(qrand()%10));
     }
     //password1=temp;


     temp.clear();
     qsrand(date.year()%10+date.month()+date.day()+1);
     for(i=0;i<8;i++)
     {
         temp.append(QString::number(qrand()%10));
     }
     mySystemPassword=temp;
 }

博文索引  持续更新中。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值