Beispiel #1
0
    def __init__(self, qml):
        super().__init__(sys.argv)
        '''
    Register our Python models (classes/types to be registered with QML.)
    '''
        model = QmlModel()
        model.register()

        self.qmlMaster = QmlMaster()

        engine = QQmlApplicationEngine()
        '''
    Need this if no stdio, i.e. Android, OSX, iOS.
    OW, qWarnings to stdio.
    engine.warnings.connect(self.errors)
    '''
        engine.load(resourceMgr.urlToQMLResource(resourceSubpath=qml))
        engine.quit.connect(self.quit)

        " Keep reference to engine, used by root() "
        self.engine = engine
        '''
    Window is shown by default.
    window = self.getWindow()
    window.show()
    '''
        '''
    Suggested architecture is for model layer (Python) not to know of UI layer,
    and thus not make connections.
    The model layer can emit signals to UI layer and vice versa,
    but only the UI layer knows what connections to make
    '''
        self.makeConnections()
Beispiel #2
0
 def widgetForQMLUsingQQuickWidget(self, qmlFilename, parentWindow):
   widget = QQuickWidget()
   qurl = resourceMgr.urlToQMLResource(resourceSubpath=qmlFilename)
   widget.setSource(qurl)
   widget.show()
   " Return widget both as widget and quickThing having rootObject() "
   return widget, widget
Beispiel #3
0
 def quickViewForQML(self, qmlFilename, transientParent=None):
   '''
   Create a QQuickView for qmlFilename.
   More robust: connects to error
   '''
   
   quickView = QQuickView()
   quickView.statusChanged.connect(self.onStatusChanged)
   
   qurl = resourceMgr.urlToQMLResource(resourceSubpath=qmlFilename)
   quickView.setSource(qurl)
   '''
   Show() the enclosing QWindow?
   But this means the window for e.g. the toolbar is visible separately?
   '''
   #quickView.show()
   print("Created QQuickView for:", qurl.path())
   if transientParent is not None:
     quickView.setTransientParent(transientParent)
   return quickView
    def _createQuickViewInstance(self, subpath, delegates, interface):
        '''
    This is separate method because I experienced failures using the QQuickView(QUrl) signature:
    quietly hangs when root of qml is not descended from QQuickItem.
    Root cannot be Dialog{}; instead nest Item{ Dialog{}}
    
    Better to use the QQuickView() signature and then call setSource()
    Set env var QML_IMPORT_TRACE=1 to debug QML imports
    '''
        print("Creating quickView")
        quickView = QQuickView()

        # TEMP HACK
        # set transientParent to the app's root window.
        quickView.setTransientParent(windowMgr.getRootWindow())
        '''
    qurl = self._qmlFilenameToQUrl(subpath + interface.qmlFilename)
    '''
        qurl = resourceMgr.urlToQMLResource(resourceSubpath=subpath +
                                            interface.qmlFilename)
        print("Reading qml from:", qurl.path())
        quickView.setSource(qurl)
        return quickView
Beispiel #5
0
 def __init__(self, qml):
   super().__init__(sys.argv)
   
   '''
   Register our Python models (classes/types to be registered with QML.)
   '''
   model = QmlModel()
   model.register()
   
   self.qmlMaster = QmlMaster()
   
   engine = QQmlApplicationEngine()
   '''
   Need this if no stdio, i.e. Android, OSX, iOS.
   OW, qWarnings to stdio.
   engine.warnings.connect(self.errors)
   '''
   engine.load(resourceMgr.urlToQMLResource(resourceSubpath=qml))
   engine.quit.connect(self.quit)
   
   " Keep reference to engine, used by root() "
   self.engine = engine
   
   '''
   Window is shown by default.
   window = self.getWindow()
   window.show()
   '''
   
   '''
   Suggested architecture is for model layer (Python) not to know of UI layer,
   and thus not make connections.
   The model layer can emit signals to UI layer and vice versa,
   but only the UI layer knows what connections to make
   '''
   self.makeConnections()
Beispiel #6
0
    def setSourceOnQuickView(self, view, qmlSubpath):
        print("setSourceOnQuickView to subpath: ", qmlSubpath)

        qurl = resourceMgr.urlToQMLResource(resourceSubpath=qmlSubpath)
        view.setSource(qurl)
        print("setSource on quickview to:", qurl.path())
Beispiel #7
0
    def setSourceOnQuickView(self, view, qmlSubpath):
        print("setSourceOnQuickView to subpath: ", qmlSubpath)

        qurl = resourceMgr.urlToQMLResource(resourceSubpath=qmlSubpath)
        view.setSource(qurl)
        print("setSource on quickview to:", qurl.path())