Announcement

Collapse
No announcement yet.

Sockets and other basic problems with QML

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Sockets and other basic problems with QML

    I love QML. It always looks so pretty and runs so quick. That said, I hate programming with QML! I hate it so much that words hardly begin to describe my frustration. Things just don't go where I intend, look like I want or behave as I expect.

    Admittedly most of my frustrations come from loving python and hating javascript but I've come to the point where I want to at least give it a fighting chance. The application I'm making is a remote control for Amarok 2. Let's be honest, this is definitely lacking which is both surprising and disappointing.

    ### What I've got ###

    I have a qml interface with the essentials implemented i.e. play, pause, next and back plus space for song info. I also have a python server (very lightweight) to handle the actual interactions with amarok on the pc.

    ### What I need ###

    I need a way to communicate from the QML program to the python server. I decided I'll use the most method: sockets. How can I use sockets with QML? Anybody have any clue? As far as I can gather, all you can do with QML is pretty GUIs and some super basic programming.

    Anybody have any ideas? I want to stick to using only QT components because I want to use necessitas to port it to Android. Where are the built in libraries? How do I access things like qtcpsocket?

    ### Other ###

    How do I stop .svgz files being super blurry in the interface?

    How can I stop the elements from overflowing horribly? Click image for larger version

Name:	theotherside2.jpg
Views:	1
Size:	18.9 KB
ID:	647941

    ### Code ###

    This code works with my testing python client code but now I want to do a QML interface. So this is the python server code:

    Code:
    import subprocess
    import socket
    
    def checkStatus(command):	
    	if command == "Play":
    		subprocess.call("qdbus org.kde.amarok /Player Play",shell=True)
    	if command == "Pause":
    		subprocess.call("qdbus org.kde.amarok /Player Pause",shell=True)
    	
    	return
    
    HOST = ''
    PORT = 5505
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((HOST, PORT))
    s.listen(1)
    while True:
    	c, addr = s.accept()
    	command = c.recv(1024)
    	checkStatus(command)
    	c.close()
Working...
X