def __build_main_window(self, engine):
"""
Builds the QML interface
"""
parentcontext = engine.rootContext()
#Create a context for the family tree list
self.qmlpersonlistcontext = QtDeclarative.QDeclarativeContext(parentcontext)
#Create ListModel to use
personlistmodel = QMLPersonListModel(self.dbstate.db)
#register them in the context
self.qmlpersonlistcontext.setContextProperty('Const', self.const)
self.qmlpersonlistcontext.setContextProperty('QMLPersonList', self)
self.qmlpersonlistcontext.setContextProperty('QMLPersonListModel', personlistmodel)
#create a Component to show
self.qmlpersonlist = QtDeclarative.QDeclarativeComponent(engine)
self.qmlpersonlist.loadUrl(QtCore.QUrl.fromLocalFile(
os.path.join(ROOT_DIR, "guiQML", 'views', 'peopleview.qml')))
#and obtain the QObject of it
self.Qpersonlist = self.qmlpersonlist.create(self.qmlpersonlistcontext)
评论列表
文章目录