Temptationx / qml-sockets

Exposing Qt's C++ socket objects to QML for declarative use.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QML Sockets

Exposing Qt's C++ socket objects to QML for declarative use.

Overview

Qt says:

QML offers a highly readable, declarative, JSON-like syntax with support for imperative JavaScript expressions combined with dynamic property bindings.

Qt also provides some very useful socket objects in their QtNetwork C++ API.

However, Qt does not provide these objects in a QML API. This plugin is an attempt do so in order to simplify socket programming for basic applications. The QML API provided may not be able to handle some of the more advanced use cases, but the lowered ceremony it brings to socket programming can get you from idea to implementation in just a few lines:

import Sockets 1.0

TCPSocket {
    host: "www.the-world.com"
    port: 1025
    
    Component.onCompleted: connect()
    
    onConnected: write("Hello, World!")
    
    onRead: console.log("The World says:", message)
    
    onDisconnected: console.log("Goodbye, Cruel World...")
}

About

Exposing Qt's C++ socket objects to QML for declarative use.

License:MIT License


Languages

Language:QML 52.7%Language:C++ 40.3%Language:QMake 4.4%Language:Ruby 2.5%