日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

QML设计登陆界面

發布時間:2025/6/15 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 QML设计登陆界面 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

QML設計登陸界面


本文博客鏈接:http://blog.csdn.net/jdh99,作者:jdh,轉載請注明.


環境:

主機:WIN7

開發環境:Qt5.2


說明:

用QML設計一個應用的登陸界面


效果圖:



源代碼:

main.qml

[javascript]?view plaincopy
  • 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:?"請輸入密碼"??
  • ????????}??
  • ??
  • ????????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

    [javascript]?view plaincopy
  • 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

    [javascript]?view plaincopy
  • 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设计登陆界面的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。