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企业管理软件之一 :怎么创建数据库表
声明:该软件为本人原创作品,多年来一直在使用该软件做项目,软件本身也一直在改善,在增加新的功能.但一个人总是会有很多考虑不周全的地方,希望能找到做同类软件的同行一起探讨. 本人文笔不行,能把意思表达清 ...
随机推荐
- PHP 批量操作删除,支持单个删除
PHP 执行部分: <?php include('checkadmin.php'); header('Content-Type: text/html; charset=utf-8'); if( ...
- QT https 程序运行异常
[1]问题现象描述 利用QT的https方式访问服务器,添加了libeay32.dll 和 ssleay32.dll, 且一直都使用正常. 正常现象:返回200,且该获取的值都正常返回(即replyB ...
- PM九步法
本文转载自网络. 多年以后,当我面对那些年青的产品经理,我会想起自己当年从事的是一份高薪的工作.那是2000年,我大学毕业后在北京一家IT网站做搜索引擎PM,当时我一个月的薪水能在亚运村买一平方米房子 ...
- Linux如何编写自启动shell脚本
1.需求分析 在很多情况下,程序员都做着重复枯燥的工作,虽然这些工作也是必须的,其实这些重复性的工作可以执行脚本替代:今天笔者就如何编写自启动shell脚本减少程序员开启服务器后的环境开启工作: 2. ...
- 《CSS世界》读书笔记(九)
<!-- <CSS世界>张鑫旭著 --> content内容生成技术 1. content 辅助元素生成 清除浮动: .clear:after { content: ''; d ...
- TCP之种种连接异常
1. connect出错: (1) 若TCP客户端没有收到syn分节的响应,则返回ETIMEOUT错误:调用connect函数时,内核发送一个syn,若无响应则等待6s后再发送一个,若仍然无响应则等待 ...
- ★Pandas 零碎知识
1 修改属性 1.1 修改1列的类型属性: df['总金额'] = pd.to_numeric(df['总金额']) #转变dataframe的1列为数值型 1.2 多列设为数值型:(使用DataFr ...
- D2欧拉路,拓扑排序,和差分约束
第一题:太鼓达人:BZOJ3033 题意:给出k,求一个最长的M位01串,使其从每一个位置向后走k个得到 的M个k位01串互不相同(最后一个和第一个相邻,即是一个环).输出 字典序最小的答案. 2 ≤ ...
- Vs10.设置.高亮(20190327)
ZC:(20190327)只要使用的是 "Highlight all occurrences of selected word" 和 "Visual Assist X&q ...
- IdentityServer4服务器配置
Session认证和JWT(Json Web Token) Token认证就是基于JWT 1.Session认证 1. 用户输入其登录信息 2. 服务器验证信息是否正确,并创建一个session,然后 ...