Пример #1
0
    def testQMLFunctionCall(self):
        app = QtGui.QApplication(sys.argv)
        view = QtDeclarative.QDeclarativeView()

        obj = PythonObject()
        context = view.rootContext()
        context.setContextProperty("python", obj)
        view.setSource(
            QtCore.QUrl.fromLocalFile(adjust_filename('bug_451.qml',
                                                      __file__)))
        root = view.rootObject()
        root.simpleFunction()
        self.assertEqual(obj.called, "simpleFunction")

        root.oneArgFunction(42)
        self.assertEqual(obj.called, "oneArgFunction")
        self.assertEqual(obj.arg1, 42)

        root.twoArgFunction(10, app)
        self.assertEqual(obj.called, "twoArgFunction")
        self.assertEqual(obj.arg1, 10)
        self.assertEqual(obj.arg2, app)

        rvalue = root.returnFunction()
        self.assertEqual(obj.called, "returnFunction")
        self.assertEqual(rvalue, 42)
    def __init__(self):
        super(SystemInfoUI, self).__init__()
        self.view = QtDeclarative.QDeclarativeView()
        self.rc = self.view.rootContext()

        self.model = SystemInfoModel()
        self.rc.setContextProperty('sysinfo', self.model)

        self.view.setSource('main.qml')

        if "-no-fs" in sys.argv:
            self.view.show()
        else:
            self.view.showFullScreen()

        self.systemInfo = QSystemInfo(self)
Пример #3
0
    def __build_main_window(self):
        """
        Builds the QML interface
        """
        self.mainwindow = QtGui.QMainWindow()
        self.mainview = QtDeclarative.QDeclarativeView()
        if OPENGL:
            glw = QtOpenGL.QGLWidget()
            self.mainview.setViewport(glw)
        self.mainview.setResizeMode(
            QtDeclarative.QDeclarativeView.SizeRootObjectToView)
        self.engine = self.mainview.engine()
        self.engine.rootContext().setBaseUrl(
            QtCore.QUrl.fromLocalFile(os.path.join(ROOT_DIR, "guiQML")))

        #set up the family tree list to select from
        self.dbman = DbManager(self.dbstate, self.engine, self.load_db)
Пример #4
0
def main():
    app = QtGui.QApplication([])

    viewer = QtDeclarative.QDeclarativeView()
    context = viewer.rootContext()
    qokModel = QokModel(viewer)
    context.setContextProperty("qokModel", qokModel)
    #con is now available in the qml as con.outputStr('data')
    viewer.setSource("qok.qml")
    viewer.setWindowTitle("Openhab on Kobo")
    viewer.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView)

    #root=viewer.rootObject()
    #print ('type=%s'%type(root))
    #qokModel.callbackSignal.connect(root.updateFromCallback)#qokModel.log)

    viewer.show()

    app.exec_()
Пример #5
0
def main(argv):
    app = QtGui.QApplication(argv)
    view = QtDeclarative.QDeclarativeView()

    colors = [{
        "color": "red",
        "text": "Zeile 1"
    }, {
        "color": "green",
        "text": "Zeile 2"
    }, {
        "color": "blue",
        "text": "Zeile 3"
    }]

    context = view.rootContext()
    context.setContextProperty("colorModel", colors)

    view.setSource(QtCore.QUrl("main2.qml"))
    view.show()
    app.exec_()