qt制作qq界面

qt制作qq界面_第1张图片

 

#include "mywnd.h"
#include "ui_mywnd.h"

MyWnd::MyWnd(QWidget *parent): QWidget(parent), ui(new Ui::MyWnd)
{
    ui->setupUi(this);
    QSize s =this->size();
    qDebug()<size()<setFixedSize(650,500);
    this->setWindowTitle("QQ");
    this->setWindowIcon(QIcon("C:\\Users\\Administrator\\Desktop\\qq.png"));
    //this->setBackgroundRole(QPalette::Dark);
    this->setAutoFillBackground(true);//允许填充
  //this->setStyleSheet("background-color:rgb(0,0,255)");
  //  this->setStyleSheet("background-color:yellow");
   // this->setWindowFlag(Qt::FramelessWindowHint);

    QPushButton *btn1 = new QPushButton(this);
    btn1->resize(80,30);
    btn1->setText("登录");
    btn1->move(220,350);

    QPushButton *btn2 = new QPushButton(this);
    btn2->resize(80,30);
    btn2->setText("取消");
    btn2->move(300,350);

    QPushButton *btn3 = new QPushButton(this);
    btn3->resize(40,40);
    btn3->move(80,220);
    //btn3->setStyleSheet("background-color:yellow");
    btn3->setIcon(QIcon("C:\\Users\\Administrator\\Desktop\\qq.png"));
    btn3->setEnabled(false);

    QPushButton *btn4 = new QPushButton(this);
    btn4->resize(40,40);
    btn4->setIcon(QIcon("C:\\Users\\Administrator\\Desktop\\qq2.png"));
    btn4->move(80,250);
    btn4->setEnabled(false);

    QPushButton *btn5 = new QPushButton(this);
    btn5->resize(40,40);
    btn4->setIcon(QIcon("C:\\Users\\Administrator\\Desktop\\qq2.png"));
    btn4->move(80,250);
    btn4->setEnabled(false);
    //定义编辑器
    QLineEdit *edt1 = new QLineEdit(this);
    edt1->move(150,220);
    edt1->resize(200,40);
    //edt1->setEchoMode(QLineEdit::Password);

    QLineEdit *edt2 = new QLineEdit(this);
    edt2->move(150,250);
    edt2->resize(200,40);
    edt2->setEchoMode(QLineEdit::Password);

   // [static]QMetaObject::Conecttion
    connect
            ( btn1,
              &QPushButton::clicked,
              [=]()
    {
        QString arr1=edt1->text();
        QString arr2=edt2->text();
        if(arr1 == "qwer" && arr2 == "1234")
        {qDebug()<<"登陆成功";}
        else {qDebug()<<"登陆失败";
        edt2->clear();}
    }
    );

    connect
            ( btn2,
              &QPushButton::clicked,
              [&](){close();}
    );


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

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