Full Featured VNC Client Widget for Qt

In this post I am going to share a Qt widget that allows full control (view and control) of VNC servers over TCP/IP. Using it is as simple as dropping a QWidget on your user interface and then promoting it to QVNCClientWidget. I needed this recently but was not able to find a Qt widget or any other Qt/C++ code for that matter, that supports VNC Authentication and can be used in a  real cross-platform way. So I had to gather and write this widget piece by piece and make sure it build on all platforms supported by Qt.

Below is an example screenshot of my QVNCClientWidget running on a Windows host to control a Mac OS X that has a VNC Server setup and running in it.


Just make sure you provide the server’s IP address and password to the connectToVncServer function. Then call startFrameBufferUpdate function to start viewing and controlling the server.

vncView->connectToVncServer("", "MyPassword");

Performance is not bad but it can be better if more compression supported protocols are developed into it.

Remember to call the following function when you need to disconnect from the server.


You can use the following Bitbucket repository the get the full source code to the widget and example project all in one place and ask your questions here if you had any.


15 Replies to “Full Featured VNC Client Widget for Qt”

  1. Dear Amin,
    I have some issues with the client. When I try to connect the client to a server, it only works sometimes (and completely), the other times I just have a black screen but I can move the mouse cursor and click. The connexion seems working, but the screen is not shared. I have the impression with the logs that the parameters are not well received by the client because I have some negatives values that are not present when the connexion totally works.
    Is it the encryption/decryption parts that are not working or is it something else ?
    What do you think about it ?
    I really need your help to solve my issue, because your work is the only one that give good results on the web.
    Best regards and thanks for your time.

    1. Unfortunately I won’t be able to support you with much details because it’s been quite some time since I worked on this, but since you have the code and you’ve already tried to make it work, then perhaps you can also fix the bugs you are facing as well. To give you a reference point where you can start, I recommend reading the official protocol for VNC which is The Remote Framebuffer Protocol. Here is a link to the article:

      Sorry if I can’t help more.

  2. Hello Amin.

    It is possible to use this code to connect to a webSocket? I have to connect to a vnc server but is emitting trough a websocket……..

    1. Hi William,
      As long as the server is on an accessible server (IP address and port number) you can connect to it.
      Here’s the connect function signature:
      bool connectToVncServer(QString ip, QString password, int port = 5900);

    1. Well essentially this is just an implementation of VNC protocol with some additional features but the main part in interpreting and communication with VNC. So the answer is, yes of course it can be ported to Python, but not exactly as it is. It needs to be adapted to Python as well.

  3. Without password it won’t work as you don’t send/receive the init messages then. Mouse button ids should be bit encoded. Mouse button release shoudln’t send the button as active. Use event->buttons() instead of event->button().
    A lot of socket->reads aren’t checked, so if any of them fail (not enough data available yet) the whole communication is broken.

    Just in case someone wants to work with your example, those are the points that need to be addressed.

  4. Hi Amin,
    I’ve one problem, i can’t see the frames.
    This is the log, it’s connected from smartphone android, but in the viewer i see nothing.

    D libQVNCClient.so: ../QVNCClient/qvncclientwidget.cpp:20 (bool QVNCClientWidget::connectToVncServer(QString, QString, int)): Security Handshake
    D libQVNCClient.so: ../QVNCClient/qvncclientwidget.cpp:23 (bool QVNCClientWidget::connectToVncServer(QString, QString, int)): Server Answer : “FB 003.008\n”
    D libQVNCClient.so: ../QVNCClient/qvncclientwidget.cpp:39 (bool QVNCClientWidget::connectToVncServer(QString, QString, int)): Connection successful: response “”
    D libQVNCClient.so: ../QVNCClient/qvncclientwidget.cpp:132 (bool QVNCClientWidget::connectToVncServer(QString, QString, int)): Screen QImage(QSize(300, 200),format=4,depth=32,devicePixelRatio=1,bytesPerLine=1200,byteCount=240000)
    D libQVNCClient.so: ../QVNCClient/qvncclientwidget.cpp:202 (void QVNCClientWidget::sendFrameBufferUpdateRequest()): Response sendFrameBufferUpdate “”

    on ubuntu linux i had installe x11vnc
    Do you help me ?

        1. So does it work on macOS? I’m specifically asking about macOS since I’m not 100%sure that it works on Android, as it is (out-of-the-box).

  5. I try your program but face to somes issues.
    It is not possible to connect even if it is write connection successful !
    Check method connectToVncServer
    condition \x01 or \x02 are not available in my case small code tell me
    “Connection successful with security type \r\x85\x05\x81”

    please can you help ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.