#ifndef MENUDIALOG_H #define MENUDIALOG_H #include #include #include static QString getRandomString(int length) //获取指定长度的字符串 { qsrand(QDateTime::currentMSecsSinceEpoch());//为随机值设定一个seed const char chrs[] = "0123456789"; int chrs_size = sizeof(chrs); char* ch = new char[length + 1]; memset(ch, 0, length + 1); int randomx = 0; for (int i = 0; i < length; ++i) { randomx= rand() % (chrs_size - 1); ch[i] = chrs[randomx]; if(i % 8 == 0 && ch[i] == '0'){ //数字开头不能为0 i = i-1; } } QString ret(ch); delete[] ch; return ret; } namespace Ui { class MenuDialog; } class MenuDialog : public QDialog { Q_OBJECT public: explicit MenuDialog(QWidget *parent = nullptr); ~MenuDialog(); void uodateNumbers(); void updateImage(); private slots: void on_pushButton_exit_clicked(); private: void initUI(); Ui::MenuDialog *ui; protected: virtual void mousePressEvent(QMouseEvent *event){}; //不执行默认的事件,不然一点窗口就消失了 virtual void mouseDoubleClickEvent(QMouseEvent *event){}; virtual void mouseReleaseEvent(QMouseEvent *event){}; }; #endif // MENUDIALOG_H