예제 #1
0
 def createQuickView(self, transientParent=None):
     """
 Create empty QQuickView.
 More robust: connects to error.
 Subsequently, you should set context and then setSource()
 """
     result = QQuickView()
     result.statusChanged.connect(self.onStatusChanged)
     assert transientParent is not None
     print("transientParent is:", transientParent, transientParent.isTopLevel())
     result.setTransientParent(transientParent)
     assert result is not None
     assert isinstance(result, QQuickView)
     return result
예제 #2
0
 def createQuickView(self, transientParent=None):
     '''
 Create empty QQuickView.
 More robust: connects to error.
 Subsequently, you should set context and then setSource()
 '''
     result = QQuickView()
     result.statusChanged.connect(self.onStatusChanged)
     assert transientParent is not None
     print("transientParent is:", transientParent,
           transientParent.isTopLevel())
     result.setTransientParent(transientParent)
     assert result is not None
     assert isinstance(result, QQuickView)
     return result
예제 #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 = self.qmlFilenameToQUrl(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
예제 #4
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