在.h里定义
QStringList list;
int index;
在构造函数里加入
//设置随机数种子
qsrand(time(NULL));
list<<QString::fromLocal8Bit("点我")
<<QString::fromLocal8Bit("走位")
<<QString::fromLocal8Bit("我闪")
<<QString::fromLocal8Bit("点不到")
<<QString::fromLocal8Bit("略略略");
index = 0;
点击按钮事件
int x = rand()%this->width();
int y = rand()%this ->height;
ui->pushButton->setText(list.at(index));
index = ++index % list.size();
ui->pushButton->move(x,y);