Qt for Python UsingQtProperties/ko

From Qt Wiki
< Qt for Python UsingQtProperties
Revision as of 04:59, 5 June 2016 by AutoSpider (talk | contribs) (Change category "LanguageBindings::PySide Korean" -> "PySide")
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

한국어 English

PySide에서 Qt 속성 사용하기

PySide의

Property

함수는 Qt 및 파이썬의 속성을 한번에 정의할 수 있으며, 속성 값을 읽고 쓰는 파이썬 함수를 정의할 수 있습니다.

아래 예제는 파이썬에서 Qt 속성을 정의하고 접근하는 방법을 보여 줍니다.

class MyObject(QObject):
 def ''init''(self,startval=42):
 self.ppval = startval

def readPP(self):
 return self.ppval

def setPP(self,val):
 self.ppval = val

pp = Property(int, readPP, setPP)

obj = MyObject()
obj.pp = 47
print obj.pp

PySide의 속성에 대한 자세한 내용은 PSEP 103 을 참고하십시오.

QML 속성

QML 문서에서 선언한 객체의 속성을 사용하려면 정의한 QML 속성이 NOTIFY가 가능해야 합니다. 간단한 시그널을 선언하면 됩니다.

class Person(QtCore.QObject):
 def ''init''(self, name):
 QtCore.QObject.''init''(self)
 self._person_name = name

def _name(self):
 return self._person_name

@QtCore.Signal
 def name_changed(self): pass

name = QtCore.Property(unicode, _name, notify=name_changed)