• 大小: 1.61MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-14
  • 语言: 其他
  • 标签: Qt  猜数字  界面  

资源简介

界面精美,简单游戏...代码量少 #include #include #include Guessnum::Guessnum(QWidget *parent) : QWidget(parent), ui(new Ui::Guessnum) { ui->setupUi(this); this->t=15; this->total=0; this->randNum=0; this->showNum=0; this->flag=0; this->time_flag=0; this->show_messg=""; this->timer = new QTimer(this); this->timer->start(1000);

资源截图

代码片段和文件信息

#include “guessnum.h“
#include “ui_guessnum.h“

#include 
#include 
#include 
#include 
#include 
#include 
#include 

Guessnum::Guessnum(QWidget *parent) :
    QWidget(parent)
    ui(new Ui::Guessnum)
{
    ui->setupUi(this);
    this->t=15;
    this->total=0;
    this->randNum=0;
    this->showNum=0;
    this->flag=0;
    this->time_flag=0;
    this->show_messg=““;

    this->timer = new QTimer(this);
    this->timer->start(1000);
    ui->lcdNumberTime->display(t);

    this->movie_screen = new QMovie(this);
    ui->label_screen->setMovie(movie_screen);
    this->movie_screen->setFileName(“:/new/prefix1/image/13125047[1].gif“);
    movie_screen->start();

    this->gif = new QMovie(this);
    ui->label->setMovie(gif);
    this->gif->setFileName(“:/new/prefix1/image/6a24ab189.gif“);

    this->movie = new QMovie(this);
    ui->labelMainPic->setMovie(movie);
    this->movie->setFileName(“:/new/prefix1/image/20090129.gif“);
    movie->start();

    ui->pushButtonstart->setEnabled(false);
    ui->label->hide();
    ui->textprompt->hide();
    ui->labelError->hide();
    ui->textError->hide();
    ui->label->setScaledContents(true);
    //ui->labelMainPic->setPixmap(QPixmap(“../image/program.jpg“));

    qsrand(QTime(000).secsTo(QTime::currentTime()));      //产生随机数
    randNum = qrand()%9999+1;
    while(randNum<1000)
        randNum = qrand()%9000+999;
    qDebug()<<“**************“<
    connect(ui->pushButtonDelSIGNAL(clicked())thisSLOT(num_delete()));
    connect(this->timerSIGNAL(timeout())thisSLOT(count_down()));
    connect(ui->toolButtonSIGNAL(clicked())thisSLOT(game_start()));
    connect(ui->pushButton0SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton1SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton2SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton3SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton4SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton5SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton6SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton7SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton8SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButton9SIGNAL(clicked())thisSLOT(clicked_Num()));
    connect(ui->pushButtonExitSIGNAL(clicked())thisSLOT(exit()));
    connect(ui->pushButtonstartSIGNAL(clicked())thisSLOT(start()));
}

Guessnum::~Guessnum()
{
    delete ui;
}

void Guessnum::clicked_Num()
{
    QPushButton *button=(QPushButton *)this->sender();
    if(button!=NULL)
    {
        int num = button->text().toInt();
        if(total>999)
          total=0;
        total=total*10+num;

        qDebug()<<“====“<<“total===“<        ui->lcdNumberShowNum->setDigi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6305  2013-09-16 13:58  guessnum\guessnum.cpp

     文件        674  2013-09-15 21:07  guessnum\guessnum.h

     文件        357  2013-09-16 08:58  guessnum\guessnum.pro

     文件      13513  2013-09-24 09:37  guessnum\guessnum.pro.user

     文件      50224  2013-09-16 19:06  guessnum\guessnum.ui

     文件    1072779  2013-09-13 08:33  guessnum\image\13125047[1].gif

     文件     136455  2013-09-13 08:34  guessnum\image\20090129.gif

     文件     422648  2013-09-13 08:37  guessnum\image\6a24ab189.gif

     文件      15426  2010-11-14 11:41  guessnum\image\face-1.png

     文件      40391  2011-09-29 12:45  guessnum\image\myheart.png

     文件        269  2013-09-16 09:56  guessnum\image.qrc

     文件        185  2013-09-13 19:51  guessnum\main.cpp

     目录          0  2014-04-08 13:08  guessnum\image

     目录          0  2014-04-08 13:08  guessnum

----------- ---------  ---------- -----  ----

              1759226                    14


评论

共有 条评论