Qml和C++开发的学生信息管理软件二

隔了这么长时间才更新以前的一个小应用,十分抱歉啊,直接贴代码了,这是注册代码,我也不解释了。

import QtQuick 2.0
import Registerdialog 1.0
import QtQuick.Controls 1.0
Rectangle {
    id :newuserdialog
    //width:Screen.desktopAvailableWidth
    //height:Screen.desktopAvailableHeight
    width:288
    height:512
    visible: true
     x:300
     y:0
    Component.onCompleted: {
        x=0;
    }
    Behavior on x {
        SpringAnimation{
        spring: 1; damping: 0.2 //SpringAnimation是加速效果
        }
    }
    Text
    {
        id: title
        anchors.horizontalCenter: parent.horizontalCenter  //水平中心
        anchors.top: parent.top;
        anchors.topMargin: 7;
        text: "注册新用户"
        font.bold: true
        font.pixelSize: mainwindow.height/25;
        color: "black"
    }
/************************************function*****************************************/
  //登陆请求函数/*
  function register_reg()
     {
         //判断用户名是否有效
         if (userinput.text== "")
               {
                   message.text = "请输入用户名!"
                   message.opacity = 1
                   return
               }
          //判断密码是否有效
           if (inputPassword.text === "")
                      {
                          message.text = "请输入密码!"
                          message.opacity = 1
                          return
                      }
           if (affarmpassword.text=== "")
                      {
                          message.text = "请输入确认密码!"
                          message.opacity = 1
                          return
                      }
           if(inputPassword.text!=affarmpassword.text)
           {
               message.text = "两次输入密码不一致!"
               message.opacity = 1
               return
           }
            //显示注册动画
            load_gif.opacity = 1
            //登陆请求
             result_gui.user_id = userinput.text
             result_gui.password = inputPassword.text
             //result_gui.affarmpassword=affarmpassword
             result_gui.slot_register_req()
          }
 /*************************************************************************************/
    Regisiterdialog{
         id:result_gui
         onSig_regisiter_result:
              {
                      //关闭登陆动画
                      load_gif.opacity = 0
                      //根据登陆结果处理
                      switch (result)
                      {
                      //注册成功
                      case 0:
                          message.text = "注册成功,请重新登录"
                          message.opacity = 1
                          break;
                      //此用户名已经存在
                      case 1:
                          message.text = "注册失败:用户名已存在"
                          message.opacity = 1
                          break;
                      //注册失败
                      case 2:
                          message.text = "注册失败!"
                          message.opacity = 1
                          break;
                      case 3:
                          message.text = "请选择注册类型!"
                          message.opacity = 1
                          break;
                      }
              }
      }
/**************************************************************/
        //用户名框
        Rectangle{
              id:userrec
              height:parent.height*9/128;width:parent.width;
              anchors.left: parent.left;
              anchors.leftMargin:0;
              anchors.top: parent.top;
              anchors.topMargin: parent.height*12/128+10;
              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: 12
                  }
              }
           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: 12
                    focus: true
                    color:"black"
                    text: "刘明"
                   // MouseArea { anchors.fill: user;onClicked: user.selectAll()}
                }
            }
        }
    }
/**************************************************************/
    //密码框
   Rectangle{
                      id:passwordrec
                      height:parent.height*9/128;width:parent.width;
                      anchors.left: parent.left;
                      anchors.leftMargin:0;
                      anchors.top: userrec.top;
                      anchors.topMargin: userrec.height+9/128*parent.height-10;
                      color:"white"
                  Row{
                      spacing:1
                      Rectangle//密码框
                      {  id:password
                          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: 12
                          }
                      }
                   Rectangle//密码输入框
                   {

                    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:inputPassword
                            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: 12
                            focus: true
                            color:"black"
                            text: "123456"
                           // MouseArea { anchors.fill: user;onClicked: user.selectAll()}
                        }
                    }
                }
            }
/**************************************************************/
   //密码确认框
   Rectangle{
                 id:affarmrec
                 height:parent.height*9/128;width:parent.width;
                 anchors.left: parent.left;
                 anchors.leftMargin:0;
                 anchors.top: passwordrec.top;
                 anchors.topMargin: passwordrec.height+9/128*parent.height-10;
                 color:"white"
                 Row{
                              spacing:1
                              Rectangle//密码确认
                              {
                                  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: 12
                                  }
                              }
                           Rectangle//密码输入框
                           {
                            id:affarminputpassword
                            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:affarmpassword
                                    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: 12
                                    focus: true
                                    color:"black"
                                    text: "123456"
                                   // MouseArea { anchors.fill: user;onClicked: user.selectAll()}
                                }
                            }
                        }
                    }
/****************************注册类型*************************************/
       Rectangle {

           anchors.horizontalCenter: parent.horizontalCenter  //水平中心
           anchors.top:affarmrec.top
           anchors.topMargin: (regesierbutton.y-affarmrec.y+regesierbutton.height)/2
           ExclusiveGroup {
               id: language;
           }
           Row {
               anchors.centerIn: parent;
               spacing:loginsence.width/4.5
               CheckBox {
                   id:student;
                   text: "学生注册";
                   exclusiveGroup: language;
                   onCheckedChanged: {   if(checked){ result_gui.student=true}}

               }
               CheckBox {
                   id:teacher
                   text: "教师注册";
                   exclusiveGroup: language;
                   onCheckedChanged: {   if(checked){ result_gui.teacher=true}}
               }
           }
       }
/*************************************************************************************/
  //注册
   Rectangle{
               id: regesierbutton
               anchors.left: parent.left
               anchors.leftMargin: 6
               anchors.top: parent.top
               anchors.topMargin: affarmrec.y+75;
               width: parent.width-12;
               height: affarmrec.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: register_reg()
               }
       }

/*************************************************************************************/
  //取消
   Rectangle{
                  id: canclebutton
                  anchors.left: parent.left
                  anchors.leftMargin: 6
                  anchors.top:parent.top
                  anchors.topMargin: affarmrec.y+125;
                  width: parent.width-12;
                  height: affarmrec.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;
                      property var objectnew
                      onClicked:   {
                          objectnew= Qt.createComponent("LoginDialog.qml").createObject(newuserdialog);
                          newuserdialog.destory();
                                          }
                                     }
              }
/************************************注册动画*****************************************/
           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:userrec.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
                    }
      }
}
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值