QML设计登陆界面

本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明.



环境:

主机:WIN7

开发环境:Qt5.2

说明:

用QML设计一个应用的登陆界面

效果图:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamRoOTk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

源码:

main.qml

import QtQuick 2.0

Rectangle
{
id: login_gui width: 320; height: 480 SystemPalette { id: activePalette } //背景图片
Image
{
id: background
anchors { top: parent.top; bottom: parent.bottom }
anchors.fill: parent
source: "pics/pic1.png"
fillMode: Image.PreserveAspectCrop
} //顶烂
Item
{
id: top_bar
width: login_gui.width; height: login_gui.height * 0.05
anchors.top: login_gui.top Text
{
id: title
anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
text: "登陆"
font.bold: true
font.pointSize: login_gui.height * 0.05 * 0.7
color: "dark red"
}
} //空白栏
Item
{
id: space1
width: login_gui.width; height: login_gui.height * 0.1
anchors.top: top_bar.bottom
} //登陆框
Rectangle
{
id: rect1
width: login_gui.width * 0.8; height: login_gui.height * 0.3
anchors { top: space1.bottom; horizontalCenter: parent.horizontalCenter }
border.color: "#707070"
color: "transparent" LineInput
{
width: rect1.width * 0.8; height: rect1.height * 0.2
font_size:height * 0.7
anchors {horizontalCenter: rect1.horizontalCenter; top: rect1.top; topMargin: 8}
hint: "请输入用户号"
} LineInput
{
width: rect1.width * 0.8; height: rect1.height * 0.2
font_size:height * 0.7
anchors {horizontalCenter: rect1.horizontalCenter; bottom: btn_login.top; bottomMargin: rect1.height * 0.1}
hint: "请输入password"
} Button
{
id: btn_login
width: rect1.width * 0.35; height: rect1.height * 0.2
anchors { left: rect1.left; leftMargin: 28; bottom: rect1.bottom; bottomMargin: 8 }
text: "登陆"
//onClicked: SameGame.startNewGame()
} Button
{
id: btn_quit
width: rect1.width * 0.35; height: rect1.height * 0.2
anchors { right: rect1.right; rightMargin: 28; bottom: rect1.bottom; bottomMargin: 8 }
text: "退出"
//onClicked: SameGame.startNewGame()
}
}
}

Button.qml

import QtQuick 2.0

Rectangle {
id: container property string text: "Button" signal clicked width: buttonLabel.width + 20; height: buttonLabel.height + 5
border { width: 1; color: Qt.darker(activePalette.button) }
antialiasing: true
radius: 8 // color the button with a gradient
gradient: Gradient {
GradientStop {
position: 0.0
color: {
if (mouseArea.pressed)
return activePalette.dark
else
return activePalette.light
}
}
GradientStop { position: 1.0; color: activePalette.button }
} MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: container.clicked();
} Text {
id: buttonLabel
anchors.centerIn: container
color: activePalette.buttonText
text: container.text
}
}

LineInput.qml

import QtQuick 2.0

FocusScope {
id: wrapper property alias text: input.text
property alias hint: hint.text
property alias prefix: prefix.text
property int font_size: 18 signal accepted Rectangle {
anchors.fill: parent
border.color: "#707070"
color: "#c1c1c1"
radius: 4 Text {
id: hint
anchors { fill: parent; leftMargin: 14 }
verticalAlignment: Text.AlignVCenter
text: "Enter word"
font.pixelSize: font_size
color: "#707070"
opacity: input.length ? 0 : 1
} Text {
id: prefix
anchors { left: parent.left; leftMargin: 14; verticalCenter: parent.verticalCenter }
verticalAlignment: Text.AlignVCenter
font.pixelSize: font_size
color: "#707070"
opacity: !hint.opacity
} TextInput {
id: input
focus: true
anchors { left: prefix.right; right: parent.right; top: parent.top; bottom: parent.bottom }
verticalAlignment: Text.AlignVCenter
font.pixelSize: font_size
//color: "#707070"
color: "black"
onAccepted: wrapper.accepted()
}
}
}

QML设计登陆界面的更多相关文章

  1. QML与C++交互:登陆界面设计

    QML与C++交互:登陆界面设计 本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明. 环境: 主机:WIN7 开发环境:Qt5.2.1 说明: QML设计前 ...

  2. WDA演练一:用户登陆界面设计(二)

    一,登陆界面设计: 1.将系统编号灰显,默认初值 2.密码栏勾选密码显示,这样就不会明文显示在页面上了: Init方法中添加默认值代码: METHOD wddoinit . DATA lo_nd_zh ...

  3. WDA演练一:用户登陆界面设计(一)

    一,新建用户表: 用户和密码参考标准的.这里给用户分了几个维度,以便后面进行接下来的业务设定. 二,新建ZLY_PORTAL 程序. 除了MAIN视图外,在添加LOGON视图. 1.导入预先做好的主页 ...

  4. Qt Quick小项目 - 登陆界面

    开发环境: win8 + Qt5.11.2 说明: 用 QML 设计一个应用的登陆界面. 效果图: 新建一个 "Qt Quick Application - empty" 工程,分 ...

  5. 一个简单WPF登陆界面,包含记住密码,自动登录等功能,简洁美观

    简介:这是一个自己以前用WPF设计的登陆界面,属于一个实验性的界面窗体,如果用于产品还很有不足.但也是有一点学习价值.后台代码略有复杂,但基本上都有注释 分类,略有代码经验的一般都能看懂. 登陆界面外 ...

  6. Android仿QQ微信开场导航以及登陆界面

    相信大家对于微信等社交应用的UI界面已经都很熟悉了,该UI最值得借鉴的莫过于第一次使用的时候一些列产品介绍的图片,可以左右滑动浏览,最后 进入应用,这一效果适用于多种项目中,相信今后开发应用一定会用得 ...

  7. 用asp连接Access数据库 制作简单登陆界面

    [题外话:最近做Internet作业,在这写一个适合初学入门的ASP连接ACCESS数据库做登陆界面的简单的例子,以慰藉我一口气把以前做过的系统中的PHP代码全改成ASP代码来临时应付作业的心情... ...

  8. WPF和Expression Blend开发实例:模拟QQ登陆界面打开和关闭特效

    不管在消费者的心中腾讯是一个怎么样的模仿者抄袭者的形象,但是腾讯在软件交互上的设计一直是一流的.正如某位已故的知名产品经理所说的:设计并非外观怎样,感觉如何.设计的是产品的工作原理.我觉得腾讯掌握了其 ...

  9. 登陆界面背景动画的css样式

    为了达到更好的用户体验,登陆界面需要设计多张背景图进行动态切换 <!doctype html> <html lang="en"> <head> ...

随机推荐

  1. OD: SEHOP

    SEHOP,Structed Exception Handling Overwrite Protection,一种比 SafeSEH 更严厉的保护机制.Windows Vista SP1 开始支持 S ...

  2. hdu 2189

    //hdu2189   题意大概就是给n个人,分成多组,要求每组人数都是素数,求有多少种... 解法就是先把150以内的素数全部存入一个数组,然后利用a[j+b[i]]+=a[j];这道题一开始没理解 ...

  3. if..endif 语法

    使用 if(); elseif(); else; endif; 这一系列复杂的语句无助于 PHP 3.0 解析器的效率.因此,语法改变为: Example#1 移植:旧有 if..endif 语法 i ...

  4. jQuery mini ui 2

    1.<a class="mini-button" iconCls="icon-add" onclick="addRow()" plai ...

  5. 破解Windows Server 2003只允许3个用户远程登陆

    导读:WIN2003在使用远程桌面登录的时候,一台机器默认情况下只允许3个用户同时登录. 这很不方便.我们修改WIN2003远程桌面的连接数,可以设置3个以上用户远程桌面. 1.启动终端服务:在&qu ...

  6. PHP中的定界符格式

    <?php //nowdoc(单引号定界符) //ABC可以是任合内容,放在单引号中 $c=<<<'ABC' 这里可以是任合内容 我是历的苛夺基 本原则叶落归根在运 输费艰难田 ...

  7. UVA 305 Joseph (约瑟夫环 打表)

     Joseph  The Joseph's problem is notoriously known. For those who are not familiar with the original ...

  8. 【基础教程】推荐10+必备的 WordPress 常用插件

    1.Akismet Akismet 是 WordPress 官方推荐的一款 WordPress 防垃圾评论插件,也是默认已安装的插件. 2.WP-Postviews 最好的最流行的WordPress浏 ...

  9. curl 转载

    CURLOPT_RETURNTRANSFER 选项: curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 如果成功只将结果返回,不自动输出任何内容. 如果失败返回F ...

  10. C#操作Excel开发报表系列整理(转)

    C#操作Excel进行报表开发系列共写了七篇,也已经有很久没有新东西了,现在整理一下,方便以后查阅,如果有写新的,会同时更新.需要注意的是因为Office的版本不同,实际的代码可能会有所不同,但是都是 ...