QTday2

点击登录,登陆成功,跳转到新的界面

主函数

#include "widget.h"
#include "second.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();

    Second s;

    QObject::connect(&w, &Widget::openSecond,&s,&Second::openSecond_slot);


    return a.exec();
}

第一个界面

#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->resize(500,600);
    this->setFixedSize(500,600);
    //设置窗口标题
    this->setWindowTitle("盗版qq");
    //设置窗口图标
    this->setWindowIcon(QIcon("D://QQ下载//icon_z8w8m9orsdk//QQ"));
    //this->setStyleSheet("background-color:skyblue; color:red;");


    QLabel *lab1=new QLabel(this);
    lab1->resize(500,280);
    lab1->setStyleSheet("background-color:skyblue; color:red;");
    lab1->setPixmap(QPixmap("D:/QQ下载/icon_z8w8m9orsdk/qiongmao"));
    //设置内容为自适应
    lab1->setScaledContents(true);


    //账户
    QLabel *lab2=new QLabel("账户",this);
    lab2->resize(50,50);
    lab2->move(90,300);
    lab2->setPixmap(QPixmap("D:/QQ下载/icon_z8w8m9orsdk/denglu"));
    //设置内容为自适应
    lab2->setScaledContents(true);

    //账户行编辑器
    //QLineEdit *edit1=new QLineEdit(this);
    edit1=new QLineEdit(this);
    edit1->resize(200,50);
    edit1->move(150,300);
    edit1->setPlaceholderText("QQ号/微信/邮箱");


    //密码
    QLabel *lab3=new QLabel("密码",this);
    lab3->resize(50,50);
    lab3->move(90,360);
    lab3->setPixmap(QPixmap("D://QQ下载//icon_z8w8m9orsdk//denglumima"));
    //设置内容为自适应
    lab3->setScaledContents(true);

    //密码行编辑器
    //QLineEdit *edit2=new QLineEdit(this);
    edit2=new QLineEdit(this);
    edit2->resize(200,50);
    edit2->move(150,360);
    edit2->setPlaceholderText("密码");
    edit2->setEchoMode(QLineEdit::Password);

    //登录按钮类
    //QPushButton *btn1=new QPushButton("登录",this);
    btn1=new QPushButton("登录",this);
    btn1->resize(80,50);
    btn1->move(200,450);
    //btn1->setEnabled(false);
    //登录插入图标
    btn1->setIcon(QIcon("D://QQ下载//icon_z8w8m9orsdk//denglu_1"));
    //登录发送信号
    QObject::connect(btn1,SIGNAL(clicked()),this,SLOT(btn1_slot()));
    //QObject::connect(btn1,&QPushButton::clicked,this,Widget::btn1_slot);




    //取消按钮类
    //QPushButton *btn2=new QPushButton("取消",this);
    btn2=new QPushButton("取消",this);
    btn2->resize(80,50);
    btn2->move(300,450);
    btn2->setIcon(QIcon("D://QQ下载//icon_z8w8m9orsdk//quxiao"));
    QObject::connect(btn2,SIGNAL(clicked()),this,SLOT(btn2_slot()));





}

void Widget::btn1_slot()
{
   if(edit1->text()=="sun" && edit2->text()=="123456")
    {
        qDebug()<<"登录成功";
        this->close();
        emit openSecond();
    }
    else
    {
        qDebug()<<"登录失败";
    }
}

void Widget::btn2_slot()
{
   this->close();

}



Widget::~Widget()
{

}

第二个界面

#include "second.h"
#include "ui_second.h"

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

 void Second::openSecond_slot()
 {
     this->show();
 }

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

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值