大佬教程收集整理的这篇文章主要介绍了c – QML – 如何将变量从一个qml文件发送/传递到其他qml文件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
http://i.stack.imgur.com/MChCG.png
>主窗口 – >创建一个组件Item2.qml
> MainWindow – >创建一个组件item1.qml
> item1.qml – >创建一个组件Item3.qml
> Item3.qml – >更改/发送变量或信号到ItemII.qml(在主窗口中创建) – 如何?
有人可以写一个小例子吗?
Item1.qml
//Item 1 import QtQuick 2.1 Rectangle { width: 200 height: 100 color:"red" Text{ anchors.centerIn: parent font.pixelSize: 16 text:"Item1" width:parent.width horizontalAlignment: Text.AlignRight color:"white" } }
Item2.qml
//Item 2 import QtQuick 2.1 Rectangle { width: 100 height: 100 color:"blue" Text{ anchors.centerIn: parent font.pixelSize: 16 text:"Item2" color:"white" } }
Item3.qml
//Item 3 import QtQuick 2.1 Rectangle { id:item3 width: item3Area.pressed?90:100 height: item3Area.pressed?90:100 color:"green" signal superAwesomeSignal(String txt) Text{ anchors.centerIn: parent font.pixelSize: 16 text:"Item3" color:"white" } MouseArea{ id:item3Area anchors.fill: parent onClicked:item3.superAwesomeSignal("Hello,from Item 3 ") } }@H_271_5@main.qml
//Main.qml import QtQuick 2.0 Rectangle { width: 360 height: 360 Item1{ anchors.top: parent.top anchors.left: parent.left Item3{ id:item3 anchors.top: parent.top onSuperAwesomeSignal: item2.item3SignalReceived(txt) } } Item2{ id:item2 anchors.bottom: parent.bottom signal item3SignalReceived(String txt) onItem3SignalReceived:console.debug(txt) } }
以上是大佬教程为你收集整理的c – QML – 如何将变量从一个qml文件发送/传递到其他qml文件全部内容,希望文章能够帮你解决c – QML – 如何将变量从一个qml文件发送/传递到其他qml文件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。