一:延时等待函数
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;
}
博文索引 持续更新中。。。