1/9作业

1/9作业_第1张图片

#include "mainwindow.h"

#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    ui->label->setPixmap(QPixmap(":/QNVV5J/Podium/2023-09-09T19-58-41-084.jpg"));
    ui->label->setScaledContents(1);
    ui->label_2->setPixmap(QPixmap(":/QNVV5J/Podium/2023-09-09T21-08-24-360.jpg"));
    ui->label_2->setScaledContents(1);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
    ui->label_3->setPixmap(QPixmap(":/QNVV5J/Podium/2023-09-09T21-08-24-360.jpg"));
    ui->label_3->setScaledContents(1);
    speecher=new QTextToSpeech;
    connect(ui->sb,&QPushButton::clicked,this,&MainWindow::myslots);
    connect(ui->login,&QPushButton::clicked,this,&MainWindow::guanbi);
}

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



void MainWindow::myslots()
{
    static  int num=0;
    if(num%2==0)
    {
        this->speecher->say(ui->lineEdit->text());
    }
    else if(num%2==1)
    {
        this->speecher->say(ui->lineEdit_2->text());
    }

    num++;
}

void MainWindow::guanbi()
{
    if((ui->lineEdit->text()=="admin")&&(ui->lineEdit_2->text()=="123456"))
    {
        qDebug("登陆成功");
        this->close();
    }
    else {
        qDebug("登陆失败");
        ui->lineEdit_2->setText("");
    }
}



void MainWindow::on_sb_clicked()
{
    static  int num=0;
    if(num%3==0)
    {
        this->setStyleSheet("background-color:blue");
    }
    else if(num%3==1)
    {
        this->setStyleSheet("background-color:red");
    }
    else if(num%3==2)
    {
        this->setStyleSheet("background-color:green");
    }
    num++;
}

你可能感兴趣的:(命令模式)