2017-03-06 13 views
0

コンテキスト変数が変更されると、コード内でisOnプロパティも変更されますか?QMLプロパティのバインド

property bool isOn: { 
    if(context === undefined) 
     return false; 
    return true 
} 

答えて

3

トリックはそれを試してみるために、次のとおりです。

import QtQuick 2.7 
import QtQuick.Controls 2.0 

ApplicationWindow { 
    id: appWindow 
    width: 500 
    height: 800 
    visible: true 

    property bool isOn: { 
     if(context === undefined) 
      return false; 
     return true 
    } 
    property var context 
    Button { 
     text: isOn 
     onClicked: (context ? context = undefined : context = 1) 
    } 
} 

ヒント:

+0

はどうもありがとうございました、はい、私はそれを試してみましょう – yonutix

関連する問題