16,223
社区成员
发帖
与我相关
我的任务
分享
#include "myrand.h"
#include <QtGui>
int main(int argc,char **argv)
{
QApplication app(argc,argv);
SELECT_NUM select;
select.show();
return app.exec();
}
#include "myrand.h"
#include <QApplication>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QTime>
#include <QComboBox>
// SELECT_NUM *se=new SELECT_NUM;
SELECT_NUM::SELECT_NUM(QWidget *parent)
:QDialog(parent)
{
//QMessageBox::warning(this,tr("spereadaflkjadf"),tr("dsfasd"),QMessageBox::Yes | QMessageBox::No);
//se->continueGetNumber=true;
continueGetNumber=true;
QVBoxLayout *vlayout2=new QVBoxLayout;
QHBoxLayout *hlayout=new QHBoxLayout;
QComboBox *combo=new QComboBox;
//lee line = new QTextEdit;
line = new QLineEdit;
//lee QPushButton *buttonstop=new QPushButton;
//lee QPushButton *buttongrip=new QPushButton;
buttonstop=new QPushButton;
buttongrip=new QPushButton;
combo->insertItem(0,"class 1");
combo->insertItem(1,"class 2");
buttonstop->setText(tr("stop"));
buttongrip->setText(tr("start"));
hlayout->addWidget(buttonstop);
hlayout->addWidget(buttongrip);
hlayout->addWidget(combo);
vlayout2->addWidget(line);
vlayout2->addLayout(hlayout);
setLayout(vlayout2);
setWindowTitle(tr("start to select the student"));
connect(buttonstop,SIGNAL(clicked()),this,SLOT(stopselect()));
connect(buttongrip,SIGNAL(clicked()),this,SLOT(startselect()));
connect(combo,SIGNAL(currentIndexChanged(int)),this,SLOT(set(combo->currentIndex())));
}
void SELECT_NUM::stopselect()
{
//se->continueGetNumber=false;
continueGetNumber=false;
}
void SELECT_NUM::startselect()
{
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
int n ;
int peo=0;
QString number="a";
if(index==0)
peo=54;
else
peo=64;
while(1)
{
n = (qrand()%peo);
line->setText(QString::number(n));
QApplication::processEvents ();
//lee if(!se->continueGetNumber)
if(!continueGetNumber)
break ;
}
//
}
void SELECT_NUM::set(int a)
{
index=a;
}
#ifndef QRAND_H
#define QRAND_H
#include <QtGui>
#include <QMainWindow>
QT_FORWARD_DECLARE_CLASS(QTextEdit)
QT_FORWARD_DECLARE_CLASS(QTextCharFormat)
class SELECT_NUM:public QDialog
{
Q_OBJECT
public:
SELECT_NUM(QWidget *parent=0);
private slots:
void stopselect();
void startselect();
void set(int a );
private:
//lee QVBoxLayout *vlayout;
//lee QHBoxLayout *hlayout;
//lee QGridLayout *glayout;
QLineEdit *line;
QPushButton *buttongrip,*buttonstop,*button2,*button1;
int index;
bool continueGetNumber;
};
#endif // QRAND_H