- import QtQuick 2.12
-
- import QtQuick.Controls 1.4
- import QtQuick.Controls.Styles 1.4
- import QtQuick.Controls 2.12
- import QtQuick.Layouts 1.12
- import QtQml 2.0
- TabView {
- property string font_color: "#EFEFEF";
- onCurrentIndexChanged:
- {
- if(currentIndex==0)
- {
- //console.log("onLoaded ipaddress = ",ipaddress);
- last_tab.reset_ip();
- //这里是切换tab页的时候,根据当前切换的下标进行调用,可以根据Tab的index进行动态绘制其中的内容
- }
- }
- Tab {
- property Item ip_label:null
- property Item ip_text:null
- id: last_tab
- anchors.topMargin:40
- anchors.bottomMargin:160
- anchors.leftMargin: 100
-
- function reset_ip(){
- if(ip_label != null){
- if(ip_text.visible){
- var ipaddress = config.ipv4_address().trim();
- ip_text.text = ipaddress;
- }
- }
- }
- onLoaded:{
- ip_label = item.ip_label
- ip_text = item.ip_text
- //关键在这里,动态链接到实例化后的item中的属性。
- //item是Tab中的一个成员变量,是实例化后的具体子控件的对象
- }
- GridLayout {
- property Item ip_label:ip_address_label
- property Item ip_text:ip_address_text
- id:grid_layout
- anchors.fill: parent
- columns: 2
- flow: GridLayout.LeftToRight
- Label
- {
- id:ip_address_label;
- text: "IP 地址";
- color: font_color;
- font.pixelSize: 18;
- visible:config.ipv4_address().trim() != "";
-
- }
- Text {
- id:ip_address_text
- text: config.ipv4_address().trim()
- font.pixelSize: 18
- color: font_color
- visible:config.ipv4_address().trim() != ""
- }
-
- }