一个简单的QQ登陆界面
来源:互联网 发布:上海美工刀片批发2011 编辑:程序博客网 时间:2024/05/16 08:13
dialog.h
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QMessageBox>
#include <QGridLayout>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
//登录button以及取消button
QPushButton* loginButton;
QPushButton* cancelButton;
//账号和密码label
QLabel* name;
QLabel* password;
//输入框
QLineEdit* nameLineEdit;
QLineEdit* passwordLineEdit;
//布局
QGridLayout* layout;
explicit Dialog(QWidget *parent = 0);
~Dialog();
private slots:
void login();
void cancel();
private:
Ui::Dialog *ui;
};
#endif // DIALOG_H
dialog.m
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
//设置主窗口的标题
setWindowTitle(tr("QQ 登陆"));
//设置label标签
name = new QLabel;
name->setText(tr("账号:"));
password = new QLabel;
password->setText(tr("密码:"));
//添加输入lineEdit控件
nameLineEdit = new QLineEdit;
passwordLineEdit = new QLineEdit;
//设置密码输入框接受的内容为黑色的圆点
passwordLineEdit->setEchoMode(QLineEdit::Password);
//设置登陆和取消的按钮
loginButton = new QPushButton;
loginButton->setText(tr("登陆"));
cancelButton = new QPushButton;
cancelButton->setText(tr("取消"));
//窗口布局,添加用到的控件
layout = new QGridLayout(this);
layout->addWidget(name,0,0);
layout->addWidget(nameLineEdit,0,1);
layout->addWidget(password,1,0);
layout->addWidget(passwordLineEdit,1,1);
layout->addWidget(loginButton,2,0);
layout->addWidget(cancelButton,3,0);
//链接信号与槽
connect(loginButton,SIGNAL(clicked()),this,SLOT(login()));
connect(cancelButton,SIGNAL(clicked()),this,SLOT(cancel()));
}
//登陆按钮接收到信号之后做的处理
void Dialog::login()
{
//用户名前如果有空格按照正确的处理
// if(nameLineEdit->text().trimmed() == tr("123456") && passwordLineEdit->text() == tr("456789"))
//如果输入的账号和密码已经存在且都相同,就接受
if(nameLineEdit->text() == tr("123456") && passwordLineEdit->text() == tr("456789"))
accept();
else//显示一个警告框
{
QMessageBox::warning(this,tr("Waring"),tr("user and password waring"),QMessageBox::Yes);
//登陆不正确时,清空账户输入框和密码框,然后光标自动跳转到账户名输入框
nameLineEdit->clear();
passwordLineEdit->clear();
nameLineEdit->setFocus();
}
}
//取消操作处理
void Dialog::cancel()
{
exit(1);
}
Dialog::~Dialog()
{
delete ui;
}
0 0
- 一个简单的QQ登陆界面
- 一个简单的安卓仿qq登陆界面
- 一个简单的登陆界面
- 用Java写的一个类似QQ登陆界面的程序 Java QQ登陆界面
- 一个简单的“灰色调”登陆界面
- 一个简单的登陆界面程序
- java实现简单QQ登陆界面
- 简单的登陆界面
- 简单的登陆界面
- [安卓初学者实验]实现一个简单仿qq登陆界面
- 用Html写一个简单的登陆界面
- 一个简单大气的登陆(login)界面源码介绍学习
- Android如何制作一个简单的登陆界面
- 一个简单的密码登陆界面。C语言
- 利用Java制作一个简单的QQ登录界面
- 仿QQ概念版的登陆界面
- C#简单的登陆界面!
- QQ登陆界面
- 详解:apache启用gzip压缩方法(二)
- android平台蓝牙编程
- Yii2-多表关联查询(with、join、joinwith)示例
- 怎样删除mysql一个表中的全部数据
- 常对象、常对象成员、常成员函数
- 一个简单的QQ登陆界面
- 业务内涵分析与建模
- 队列并不能解决“超载”
- easyui 1.4.2 tree 插件的节点属性state使用注意
- DMZ的配置
- 深度学习综述(LeCun、Bengio和Hinton)
- 内网IPC$种马的三种方法
- 深入理解Redis主键失效原理及实现机制
- 陈怡暖:2015.6.4早间现货黄金白银操作建议