C

Qt VNC Server - VncChat Example

Demonstrates how to make a simple application that uses Qt VNC Server.

VncChat demonstrates the use of the Qt VNC Server module.

The example is a very basic and disorganized chat application, which consists of a text editor that is exposed to VNC®-compatible clients and can be edited by anyone at any time.

The text editor and its frame is wrapped by a VncItem which causes it to automatically be shared over the connection:

VncItem {
    id: grabber
    anchors.fill: parent

    Rectangle {
        id: editorFrame
        anchors.fill: parent
        anchors.margins: window.width * 0.1
        radius: window.width * 0.1

        color: "gainsboro"
        TextArea {
            id: textArea
            anchors.fill: parent
            anchors.margins: window.width * 0.1
            background: null
            placeholderText: "Say something nice"
            placeholderTextColor: "darkslategrey"
        }
    }
}

Only the contents of the VncItem will be shared, so the colored frame around it and application title will only be visible locally.

Default values are used for all properties, which means the server will be listening to port 5900. For convenience, this information is provided in a label at the top:

Label {
    id: portLabel
    anchors.top: titleLabel.bottom
    anchors.horizontalCenter: activeRect.horizontalCenter
    text: "(Port " + grabber.vncPort + " is open for business)"
    font.pixelSize: window.height * 0.015
}

Finally, the locally running application has a frame around the VncItem which changes color depending on whether a client is connected or not. In the screenshot, this is dark sea green, indicating that a client has connected. When no client is connected, it will be the color 'salmon':

color: grabber.connectionActive ? "darkseagreen" : "salmon"

Files:

Available under certain Qt licenses.
Find out more.