Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. need help to translate python script to Qt quick qml code
QtWS25 Last Chance

need help to translate python script to Qt quick qml code

Scheduled Pinned Locked Moved QML and Qt Quick
qt quickpythonqmltranslate
2 Posts 2 Posters 1.2k Views
  • 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 Offline
    A Offline
    antemort
    wrote on 15 Jun 2015, 11:24 last edited by p3c0
    #1

    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.

    P 1 Reply Last reply 15 Jun 2015, 11:37
    0
    • A antemort
      15 Jun 2015, 11:24

      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.

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 15 Jun 2015, 11:37 last edited by p3c0
      #2

      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
      0

      1/2

      15 Jun 2015, 11:24

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved