Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    need help to translate python script to Qt quick qml code

    QML and Qt Quick
    qt quick python qml translate
    2
    2
    947
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      antemort last edited by p3c0

      Hi, I am wondering if somebody could help me to translate py- code to Qt qml code because i have one code script in py and one in qml.

      The py code looks like this

      from socket import *
      
      HOST = ''
      PORT = 8001
      ADDR = (HOST, PORT)
      
      serversock = socket(AF_INET, SOCK_STREAM)
      serversock.bind(ADDR)
      serversock.listen(2)
      
      
      while 1:
          print("Wait for connection")
          clientsock, addr = serversock.accept()
          print('Connected from' + str(addr))
          while 1:
              data = clientsock.recv(2048)    
              print(data)
          
      serversock.close()
      

      and i wont to translate it and use 'data' variable as angle in my ui in qml. please help me.

      p3c0 1 Reply Last reply Reply Quote 0
      • p3c0
        p3c0 Moderators @antemort last edited by p3c0

        Hi @antemort,
        It can't be done purely in QML. You will need to use sockets on C++ side. Qt has C++ API's for sockets. QTcpServer creates a server and QTcpSocket for client. After that you will need to expose them to QML.
        Edit: Some one has tried to do that already. See https://github.com/jemc/qml-sockets

        157

        1 Reply Last reply Reply Quote 0
        • First post
          Last post