def viewload():
    app = QGuiApplication(sys.argv)
    view = QQuickView()
    view_model = URControlViewModel()
    ur_singal = view_model.gui
    view.rootContext().setContextProperty("urSingal", ur_singal)
    # qmlRegisterType(UIsignal, 'PySignal', 1, 0, 'PySignal') # implicit error when using slot and singal
    qmlRegisterType(ur_visual.FboItem, "QmlVTK", 1, 0, "VtkFboItem")

    view.setSource(QUrl.fromLocalFile(abs_path("qmlRobotGui\main.qml")))
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setTitle("UR Controller")
    if view.status() == QQuickView.Error:
        sys.exit(-1)
    view.show()

    root_obj = view.rootObject()
    view_model.init_connect(root_obj)
    root_obj.destroyed.connect(view_model.disconnectRobot)

    app.exec_()
    # Deleting the view before it goes out of scope is required to make
    # sure all child QML instances are destroyed in the correct order.
    del view
Пример #2
0
## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
##
## $QT_END_LICENSE$
##
#############################################################################
"""PySide2 port of the QML Polar Chart Example from Qt v5.x"""

import sys
import os
from PySide2.QtQuick import QQuickView
from PySide2.QtCore import Qt, QUrl
from PySide2.QtWidgets import QApplication, QMainWindow

if __name__ == '__main__':
    app = QApplication(sys.argv)
    viewer = QQuickView()

    viewer.engine().addImportPath(os.path.dirname(__file__))
    viewer.engine().quit.connect(viewer.close)

    viewer.setTitle = "QML Polar Chart"
    qmlFile = os.path.join(os.path.dirname(__file__), 'main.qml')
    viewer.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile)))
    viewer.setResizeMode(QQuickView.SizeRootObjectToView)
    viewer.show()

    sys.exit(app.exec_())