QT实现登录功能

代码如下:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->passwordlineEdit->setEchoMode(QLineEdit::Password);
}

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

void MainWindow::on_loginpushButton_clicked()
{
    if((ui->usernamelineEdit->text() == "duola") && (ui->passwordlineEdit->text() == "Ameng"))
    {
        QMessageBox::information(this,"GOOD","login success");

    }
    else{
        QMessageBox::information(this,"Permission Deny!","please check your username and passowrd");
        return ;
    }
}

界面代码如下:



 MainWindow
 
  
   
    0
    0
    <

你可能感兴趣的:(图形界面QT,C++)