|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 alltolove 于 2017-3-8 09:51 编辑
效果:
图片都是从论坛帖子里来的
知识点1:学会连接网络图片
知识点2:像CSS样式表一样给各种控件制定样式
代码如下:
main.qml文件:
复制代码
MainForm.ui.qml文件:
- import QtQuick 2.5
- import QtQuick.Controls 1.2
- import QtQuick.Controls.Styles 1.3//想用自定义样式必须引入
- Item {
- property alias one: one
- property alias two: two
- property alias three:three
- property alias a: a
- property alias b: b
- property alias c: c
- width: 360
- height: 360
- Text {
- id:one
- anchors.horizontalCenter: parent.horizontalCenter
- text: "图1"
- font.family: "仿宋"
- font.pixelSize: 24
- visible: false
- }
- Text {
- id:two
- anchors.horizontalCenter: parent.horizontalCenter
- text: "图2"
- font.family: "仿宋"
- font.pixelSize: 24
- visible:false
- }
- Text {
- id:three
- anchors.horizontalCenter: parent.horizontalCenter
- text: "图3"
- font.family: "仿宋"
- font.pixelSize: 24
- visible:false
- }
- property Component buttonStyle:ButtonStyle{//定制一个样式
- background:Rectangle{
- implicitWidth: 50
- implicitHeight: 30
- border.width: 2
- border.color: "green"
- color:"yellow"
- }
- }
- Column{
- spacing: 10
- Button{id:a;style:buttonStyle;text:"图片1"}
- Button{id:b;style:buttonStyle;text:"图片2"}
- Button{id:c;style:buttonStyle;text:"图片3"}
- }
- }
复制代码
Preview: 明天介绍怎么用菜单栏 |
评分
-
查看全部评分
|