QT第二界面跳转

 

 

 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();
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值