qt 简单登录界面(一)
widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include<QLineEdit>
class Widget : public QWidget
{
Q_OBJECT
public slots:
void foo();
public:
Widget(QWidget *parent = 0);
~Widget();
QLineEdit *userEdit;
QLineEdit * passwdEdit;
}; #endif // WIDGET_H
widget.cpp
#include "widget.h"
#include<QBoxLayout>
#include<QGridLayout>
#include<QPushButton>
#include<QLabel>
#include<QLineEdit>
#include<QDebug>
#include <QApplication>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
QGridLayout* grid=new QGridLayout(this);
QHBoxLayout* hbox=new QHBoxLayout(this);
QPushButton *ok=new QPushButton("确认");
QPushButton *cancel=new QPushButton("取消");
QLabel *userLabel= new QLabel("用户:");
userEdit=new QLineEdit;
QLabel* passwdLabel=new QLabel("密码:");
passwdEdit=new QLineEdit; passwdEdit->setEchoMode(QLineEdit::Password);
grid->addWidget(userLabel,0,0,1,1);
grid->addWidget(userEdit,0,1,1,1);
grid->addWidget(passwdLabel,1,0,1,1);
grid->addWidget(passwdEdit,1,1,1,1); hbox->addWidget(ok);
hbox->addWidget(cancel); grid->addLayout(hbox,2,0,1,2);
this->setLayout(grid); connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
connect(ok,SIGNAL(clicked()),this,SLOT(foo())); }
void Widget::foo()
{
if(userEdit->text()=="admin")
{
if(passwdEdit->text()=="123456")
{
qDebug()<<"登录成功"<<endl;
}
else
{
qDebug()<<"密码错误"<<endl;
}
}
else {
qDebug()<<"用户名不存在"<<endl;
}
}
Widget::~Widget()
{ }
main.cpp:
#include "widget.h"
#include <QApplication> int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.resize(500,300);
w.show(); return a.exec();
}
输出:

qt 简单登录界面(一)的更多相关文章
- Cookie案例:简单登录界面中的应用
ServletDemo1.java package ztq.servlet.study; import java.io.IOException; import java.io.PrintWriter; ...
- 以java实现的一个简单登录界面(带验证码)
本文参考于:https://blog.csdn.net/wyf2017/article/details/78831744 https://blog.csdn.net/MengKun822/articl ...
- Qt 用户登录界面
使用QT创建自己的登录窗口: 主要步骤: 1.窗口界面的绘制 2.沟通数据库进行密码验证 void MainWindow::on_pushButton_clicked() { // 连 ...
- 一个基于QT简单登录对话框
1. 登录对话框式样 2. QLoginDialog.h #ifndef DIALOG_H #define DIALOG_H #include <QtGui/QDialog> #inclu ...
- JSP内置对象的cookie和session实现简单登录界面
创建一个index.jsp页面 <%@ page language="java" contentType="text/html; charset=utf-8&quo ...
- 一个基于QT简单登录对话框(带验证码功能)
1. 对话框样式 2. 源代码 ①. main.cpp #include <QtGui/QApplication> #include "QLoginDialog.h" ...
- JAVA语言实现简单登录界面
程序设计思想: 使用Math.random()方法循环生成6个97~122之间的随机整数(对应ASCII码值‘a’~‘z’),将其转化为char型变量,连接成为一个6位字符串作为验证码输出,提示用户输 ...
- 设计简单登录界面(Java web)
程序设计思想: 在Input.jsp中创建一个表格里边分别是课程名称,任课老师,教学地点,并分别用三个文本框来接受输入的三个属性, 并传到另外的Jsp页面中,又来接受三个数据,并判断传来的教师,与教室 ...
- Java简单登录图形界面
本文参考与:https://blog.csdn.net/wyf2017/article/details/78831744 https://blog.csdn.net/MengKun822/articl ...
随机推荐
- Spring支持的常用数据库传播属性和事务隔离级别
一.事务的传播属性 1.propagation:用来设置事务的传播行为,一个方法运行在了一个开启了事务的方法中时,当前方法是使用原来的事务还是开启一个新的事务. (1)propagation.REQU ...
- IDEA结合mybatis插件自动生成代码
pom文件 添加插件 <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>myb ...
- 【LeetCode】1403. 非递增顺序的最小子序列 Minimum Subsequence in Non-Increasing Order
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 贪心 日期 题目地址:https://leetcode ...
- 【剑指Offer】二叉搜索树的后序遍历序列 解题报告(Python)
[剑指Offer]二叉搜索树的后序遍历序列 解题报告(Python) 标签(空格分隔): 剑指Offer 题目地址:https://www.nowcoder.com/ta/coding-intervi ...
- light oj 1100 - Again Array Queries(暴力,鸽巢原理)
http://lightoj.com/volume_showproblem.php?problem=1100 刚一看到这题,要询问这么多次,线段树吧,想多了哈哈,根本没法用线段树做. 然后看看数据范围 ...
- 1016 - Brush (II)
1016 - Brush (II) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Afte ...
- MySQL数据库安装Version5.7.25
1.说明 MySQL数据库大版本5.7的安装没有较大变化, 所以MySQL数据库Version5.7.25安装请参考:MySQL数据库安装Version5.7 上面文章中MySQL安装使用Versio ...
- Elasticsearch安装X-Pack插件
Elasticsearch安装X-Pack插件, 基于已经安装好的6.2.2版本的Elasticsearch, 安装6.2.2版本的X-Pack插件. 1.下载x-pack的zip包到本地 https ...
- .net core集成使用EasyNetQ来使用rabbitmq
之前有写到一篇介绍EasyNetQ的博文(C# .net 使用rabbitmq消息队列--EasyNetQ插件介绍),所以本文从.net core的角度去继承使用EasyNetQ,而用法类似于之前集成 ...
- sqlplus -S参数表示什么意思?
sqlplus -S , -S选项是静默模式,是Silent的缩写.在这种模式下将会以最精简的形式完成SQL*Plus的交互过程. -S模式多用于脚本模式.在命令行sqlplus -S还有可能出现卡住 ...