Qml和C++开发的学生信息管理软件一
一个月前接触到了Qml,也做过一些练习,但只能实现动画和简单的布局功能,逻辑部分和数据处理很难上手,看到许多人将C++和结合起来,Qml负责界面设计,C++实现逻辑处理,但将C++注册到 Qml中一直让我头疼,比如属性声明和函数声明类想不通为什么这么做,可能是时间问题吧,慢慢的就发现了其实也不难,花了好几天做成了这个小应用,算是这一阶段的小小纪念吧。
下来就是贴代码的时间了.
先是main.qml
启动时先进入登录界面
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 1.0
import Login_gui 1.0
import QtQuick.Particles 2.0
Window {
visible: true
id:mainwindow
width: 300
height: 533
color: "#F0F0F0"
LoginDialog {}
}
LoginDialog的代码如下:
import QtQuick 2.0
import Login_gui 1.0
import QtQuick.Controls 1.1
Rectangle {
id:loginsence
width: 300
height: 533
color: "#F0F0F0"
visible: true
x:300
Component.onCompleted: {
x=0;
}
Behavior on x {
NumberAnimation {easing.type:Easing.OutQuint;duration: 1100}//OutQuint动画效果 结束时速度变慢
}
property string userselect
/*************************************************************************************/
//登陆请求函数
function login_req()
{
//判断用户名是否有效
if (userinput.text== "")
{
message.text = "请输入用户名!"
message.opacity = 1
return
}
//判断密码是否有效
if (passwordinput.text == "")
{
message.text = "请输入密码!"
message.opacity = 1
return
}
//显示登陆动画
load_gif.opacity = 1
//登陆请求
//console.log("***********************")
login_gui.user_id = userinput.text
login_gui.password = passwordinput.text
login_gui.slot_login_req()
}
/*************************************************************************************/
Login_gui{
id:login_gui
property var loginstudent
onSig_login_result:
{
//关闭登陆动画
load_gif.opacity = 0
//根据登陆结果处理
switch (result)
{
//登陆成功
case 0:
message.text = "登陆成功"
message.opacity = 1
if(userselect=="studentselect " )
{ loginstudent= Qt.createComponent("StudentDialog.qml").createObject(loginsence);break; }
else
{ loginstudent= Qt.createComponent("TeacherDialog.qml").createObject(loginsence);break; }
//无此用户名
case 1:
message.text = "登陆失败:无此用户名"
message.opacity = 1
break;
//密码错误
case 2:
message.text = "登陆失败:密码错误"
message.opacity = 1
break;
case 3:
message.text = "登陆失败:请选择登录类型"
message.opacity = 1
}
}
}
/************************************************************************/
Rectangle //顶栏
{
id: top_bar
anchors.left: parent.left;
anchors.leftMargin: parent.width/2;
anchors.top: parent.top;
anchors.topMargin: 10;
border.color: "#707070"
Text
{
id: title
anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
text: "登陆"
font.bold: true
font.pixelSize: mainwindow.height/25;
color: "blue"
}
}
/**************************************************************/
//用户名框
Rectangle{
id:loginBox
height:parent.height/16;width:parent.width;
anchors.left: parent.left;
anchors.leftMargin:0;
anchors.top: parent.top;
anchors.topMargin: 150;
color:"white"
Row{
spacing:1
Rectangle//用户名框
{ id:user
height:loginBox.height;width:loginBox.width/4;
anchors.left: loginBox.left;
anchors.leftMargin:0;
anchors.bottom: loginBox.bottom;
anchors.bottomMargin: 0;
Text{
text: "用户名:";
anchors.left: parent.left;
anchors.leftMargin:0;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 0;
font.bold:false
font.family: "微软雅黑"
color:"black"
font.pointSize: 15
}
}
Rectangle//用户名输入框
{
id:loginuser
height:loginBox.height;width:loginBox.width-user.width;
anchors.left: loginBox.left;
anchors.leftMargin:user.width;
anchors.bottom: loginBox.bottom;
anchors.bottomMargin: 0;
TextInput
{ id:userinput
anchors.left: parent.left;
anchors.leftMargin:0;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 0;
width: parent.width
height: parent.height/2
font.family: "微软雅黑"
font.pointSize: 15
focus: true
color:"black"
text: "王红"
// MouseArea { anchors.fill: user;onClicked: user.selectAll()}
}
}
}
}
/************************************************************************/
//密码框
Rectangle{
id:passwordBox
height:parent.height/16;width:parent.width;
anchors.left: parent.left;
anchors.leftMargin:0;
anchors.top: parent.top;
anchors.topMargin: loginBox.height+151;
color:"white"
Row{
spacing: 1
Rectangle//密码框
{ id:password
height:passwordBox.height;width:passwordBox.width/4;
anchors.left: passwordBox.left;
anchors.leftMargin:0;
anchors.bottom: passwordBox.bottom;
anchors.bottomMargin: 0;
Text{
text: "密 码:";
anchors.left: parent.left;
anchors.leftMargin:0;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 0;
font.family: "微软雅黑"
font.pointSize: 15
}
}
Rectangle{ //密码输入框
id:loginpassword
height:passwordBox.height;width:passwordBox.width-password.width;
anchors.left: passwordBox.left;
anchors.leftMargin:password.width;
anchors.bottom: passwordBox.bottom;
anchors.bottomMargin: 0;
color:"white"
TextInput{
id:passwordinput
text: "1234567"
anchors.left: parent.left;
anchors.leftMargin:0;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 0;
width: parent.width
height: parent.height/2
font.family: "微软雅黑"
font.pointSize: 15
// MouseArea { anchors.fill: password;onClicked: password.selectAll()}
}
}
}
}
/************************************登录*******************************************/
Rectangle{
id: loginbutton
anchors.left: parent.left
anchors.leftMargin: 6
anchors.top: passwordBox.top
anchors.topMargin: parent.width/4.2;
width: parent.width-12;
height: passwordBox.height;
radius: 5 //倒角
color:"#19cff7"
Text{
anchors.horizontalCenter: parent.horizontalCenter //水平中心
anchors.verticalCenter:parent.verticalCenter //垂直中心
text:"登录"
font.family: "华文细黑"
styleColor: "white"
font.pointSize: 15
}
MouseArea {
anchors.fill: parent;
onClicked:{console.log(passwordinput.text); login_req()}
}
}
/************************************登录动画*****************************************/
AnimatedImage
{
id: load_gif ;
source: "qrc:/new/prefix1/image/login.gif"
anchors {horizontalCenter: mainwindow.horizontalCenter;verticalCenter:mainwindow.verticalCenter}
y: 180; x:90
opacity: 0
}
/***************************************信息框*************************************/
Rectangle{
anchors.horizontalCenter: parent.horizontalCenter //水平中心
anchors.bottom: loginBox.bottom
anchors.bottomMargin:45;
width: loginbutton.width/2;
height: loginbutton.height/2;
radius: 3 //倒角
color: "#F0F0F0"
Text{
id:message
anchors.horizontalCenter: parent.horizontalCenter //水平中心
anchors.verticalCenter:parent.verticalCenter //垂直中心
font.family: "华文细黑"
styleColor: "black"
font.pointSize: 10
opacity: 0
}
}
/****************************注册*************************************/
Rectangle{
id:newuserrer
anchors.right: parent.right;
anchors.rightMargin: 28;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 35;
Text
{
id: newuser
anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
text: "新用户"
font.family: "华文细黑"
font.pixelSize: 12
color: "#3aa7ea"
MouseArea {
anchors.fill: parent;
property var login
onClicked:
{
login= Qt.createComponent("NewUserDialog.qml").createObject(loginsence);
loginsence.deleteLater();
}
}
}
}
/****************************登录类型*************************************/
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter //水平中心
anchors.bottom:loginbutton.bottom;
anchors.bottomMargin: (loginbutton.y-passwordBox.y+loginbutton.height)/2
ExclusiveGroup {
id: language;
}
Row {
anchors.centerIn: parent;
spacing:loginsence.width/4.5
CheckBox {
id:student
text: "学生登录";
exclusiveGroup: language;
onCheckedChanged: { if(checked){login_gui.student=true;login_gui.teacher=false;userselect="studentselect " } }
}
CheckBox {
id:teacher
text: "教师登录";
exclusiveGroup: language;
onCheckedChanged: { if(checked){ login_gui.teacher=true;login_gui.student=false;userselect="teacherselect"} }
}
}
}
/************************************************************************************/
}
没什么难点,主要是界面布局费点事,定义了一个属性property string userselect来标标识是管理员登录还是学生登录,以便进图不同的界面。还有就是使用Textinput是,需要设置高度和宽度,否则无法输入文字,这个很是奇怪,我觉得软件做的不够人性化,好了,今天就先到这里了。
Qml和C++开发的学生信息管理软件一的更多相关文章
- 企业信息管理软件 OA、CRM、PM、HR 财务、ERP等
本文就企业信息管理软件做一个记录. 最近公司要开发物料管理系统....于是查找一些资料 Excel垄断企业信息管理软件二三十年无人撼动:OA.CRM.PM.HR软件不温不火难以普及. 已有的信息化市场 ...
- 【学员管理系统】0x02 学生信息管理功能
[学员管理系统]0x02 学生信息管理功能 写在前面 项目详细需求参见:Django项目之[学员管理系统] Django框架大致处理流程 捋一下Django框架相关的内容: 浏览器输入URL到页面展示 ...
- 一起来开发Android的天气软件(三)——使用Volley实现网络通信
距离上一篇一起来开发Android天气软件二的时间又将近半个月了,之间一直由于有事而没有更新实在抱歉,近期会加快更新的步伐.争取在2015年到来前写完这系列的博文,上一章我们已经使用LitePal框架 ...
- 个人整理的 Windows 下 .NET 开发必装的软件
注: 最后更新时间:2019-03-15 一..NET 开发 1. 必装 软件名称 说明 下载地址 JetBrains Toolbox JetBrins 全家桶管理工具. 下载地址 JetBrains ...
- 术语-软件-软件开发:SDK(软件开发工具包)
ylbtech-术语-软件-软件开发:SDK(软件开发工具包) 软件开发工具包(缩写:SDK.外语全称:Software Development Kit)一般都是一些软件工程师为特定的软件包.软件框架 ...
- c#开发地磅称重软件
2012年时即做过一个地磅称重软件,最近公司又接了一个地磅过磅软件的项目,把遇到的问题总结一下以备后用. 1.接线问题 因为客户方原来单独使用仪表,仪表未有接线和电脑连接,为此颇费周折才做好了接线.接 ...
- window下的开发环境:常用软件
window下的开发环境:常用软件 Visio 2010 - 产品设计 xmind -产品设计 Axure -产品设计 Edraw max 7.3(破解版) -产品设计 ...
- python开发的学生管理系统
python开发的学生管理系统(基础版) #定义一个函数,显示可以使用的功能列表给用户 def showInfo(): print("-"*30) print(" 学生管 ...
- "零代码”开发B/S企业管理软件之一 :怎么创建数据库表
声明:该软件为本人原创作品,多年来一直在使用该软件做项目,软件本身也一直在改善,在增加新的功能.但一个人总是会有很多考虑不周全的地方,希望能找到做同类软件的同行一起探讨. 本人文笔不行,能把意思表达清 ...
随机推荐
- Java课程总结
预备作业一 简要内容:我期望的师生关系 预备作业二 简要内容:学习基础和C语言基础调查 预备作业三 简要内容:Linux安装及学习 第一周作业 简要内容:Java入门 第二周作业 简要内容:学习基本数 ...
- 史上最全的PHP常用函数大全,不看看你就out了(还会不断更新哦!)
纪录了PHP的一些常用函数和函数代码!不要错过了哦. PHP的一些常用函数usleep() 函数延迟代码执行若干微秒.unpack() 函数从二进制字符串对数据进行解包.uniqid() 函数基于以微 ...
- 利用JS打印质数
我爱撸码,撸码使我感到快乐!大家好,我是Counter,今天非常愉快,没有前几天的相对比较复杂的逻辑思维在里面,今天来写写,利用JS打印质数,基本上很多面试,会很经常的考到.那废话不多说,直接上代码: ...
- 【HNOI 2018】寻宝游戏
Problem Description 某大学每年都会有一次 \(Mystery\ Hunt\) 的活动,玩家需要根据设置的线索解谜,找到宝藏的位置,前一年获胜的队伍可以获得这一年出题的机会. 作为新 ...
- 如何用 python 优雅地完成数据库课设
0 前言 偶然间发现 Google 收录了学校实验打卡系统的接口,正好要做数据库课设,便拿来作为 environment. 机房居然装了 python ,早就听说 python 写爬虫速度一流,课上的 ...
- 获取添加数据的自增ID
$id= DB::select("select auto_increment from information_schema.`TABLES` where table_name='stude ...
- iOS关于直播的链接
iOS关于直播集成的链接 http://www.jianshu.com/p/7b2f1df74420 https://www.cnblogs.com/graveliang/p/5683617.html ...
- Bioconductor软件安装与升级
1 安装工具Bioc的软件包不能使用直接install.packages函数,它有自己的安装工具,使用下面的代码: source("https://bioconductor.org/bioc ...
- 线程(四)之Queue
SynchronousQueue SynchronousQueue是无界的,是一种无缓冲的等待队列,但是由于该Queue本身的特性,在某次添加元素后必须等待其他线程取走后才能继续添加:可以认为Sync ...
- 【分布式搜索引擎】Elasticsearch写入和读取数据过程
一.Elasticsearch写人数据的过程 1)客户端选择一个node发送请求过去,这个node就是coordinating node(协调节点)2)coordinating node,对docum ...