QT第二界面跳转

 QT第二界面跳转_第1张图片

 

 widget:

#include "widget.h"
#include "ui_widget.h"


void Widget::my_slots()
{
    QString userName=this->edit1->text();
    QString pwd=this->edit2->text();
    if((userName=="1") && (pwd=="1"))
    {
        qDebug() << "登录成功" ;
        emit jump();
        speecher->say("哈哈哈哈");
        this->close();
    }
    else
    {
        qDebug() << "登录失败" ;
        speecher->say("嘻嘻嘻嘻");
    }
}

void Widget::btn2_slots()
{
    close();
}

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setFixedSize(640,520);
    //设置窗口标题
    this->setWindowTitle("QQ");
    //设置窗口图标
    this->setWindowIcon(QIcon(":/Logo/44.png"));//在本路径下添加资源文件,鼠标放在这里会显示图片s
//    this->setStyleSheet("background-color:white");
    this->setStyleSheet("background-image:url(:/Logo/99.png);");
    //this->setWindowOpacity(0.);

    //定义一个标签,并直接指定父组件,(背景)
    lab1 = new QLabel("背景",this);
    movie = new QMovie(":/Logo/12.gif");
    lab1->setMovie(movie);
    movie->start();
    lab1->adjustSize();
//    lab1->setPixmap(QPixmap(":/Logo/beijing.png"));
//    lab1->resize(640,200);

    //头像
    lab4 = new QLabel("头像",this);
    lab4->setFont(QFont("微软雅黑",40));
    lab4->move(240,140);
    lab4->resize(100,100);
    lab4->setPixmap(QPixmap(":/Logo/99.png"));
    lab4->setStyleSheet("border-radius:50%");
    //自适应大小
    lab4->setScaledContents(true);
    //lab4->setWindowOpacity(0.8);

    //账号密码
    lab5 = new QLabel("账号",this);
    lab5->resize(33,40);
    lab5->move(155,261);
    lab5->setPixmap(QPixmap(":/Logo/44.png"));
    lab5->setScaledContents(true);

    lab6 = new QLabel("密码",this);
    lab6->resize(19,29);
    lab6->move(160,315);
    lab6->setPixmap(QPixmap(":/Logo/denglumima.png"));
    lab6->setScaledContents(true);

    //设置行编辑器
    edit1 = new QLineEdit(this);
    edit1->resize(230,44);
    edit1->move(190,260);
    edit1->setStyleSheet("border:none");//像素1px
    //设置占位文本
    edit1->setPlaceholderText("QQ号/手机号/邮箱");
    edit1->setStyleSheet("background-color:rgba(255,255,255,0);");

    edit2 = new QLineEdit(this);
    edit2->resize(230,44);
    edit2->move(190,313);
    edit2->setStyleSheet("border:none");//像素1px
    //设置占位文本
    edit2->setPlaceholderText("密码");
    edit2->setEchoMode(QLineEdit::Password);
    edit2->setStyleSheet("background-color:rgba(255,255,255,0);");

    //按钮
    btn1 = new QPushButton(QIcon(":/Logo/denglu_1.png"), "登录", this);
    btn1->resize(120,60);
    btn1->move(165,360);
    btn1->setStyleSheet("background-color:skyblue;border-radius:10");
    //QT4版本手动连接函数
    connect(this->btn1,SIGNAL(clicked()),this,SLOT(my_slots()));
    speecher = new QTextToSpeech(this);
    //登录按钮连接jump函数
    //connect(this->btn1,&QPushButton::clicked,this,&Widget::jump);


    btn2 = new QPushButton(QIcon(":/Logo/quxiao.png"), "取消", this);
    btn2->resize(btn1->size());
    btn2->move(310,360);
    btn2->setStyleSheet("background-color:skyblue;border-radius:10");
    connect(btn2,&QPushButton::clicked,this,&Widget::btn2_slots);
}

Widget::~Widget()
{
    delete ui;
    delete movie;
}

scond:

#include "scond.h"
#include "ui_scond.h"

scond::scond(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::scond)
{
    ui->setupUi(this);

    this->setFixedSize(420,830);
    //设置窗口标题
    this->setWindowTitle(" ");
    //设置窗口图标
    this->setWindowIcon(QIcon(":/Logo/44.png"));
    this->setStyleSheet("background-image:url(:/Logo/99.png);");


}

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

void scond::jump_slots()
{
    this->show();
}

你可能感兴趣的:(qt,开发语言)