by Kakadu

Kakadu / lablqml

Interfacing Qt/QML with OCaml. Formely known as lablqt

132 Stars 13 Forks Last release: Not found 671 Commits 21 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Build Status

Let's write QML/QtQuick GUI for OCaml (or Reason) using lablqml!

In this repo you can find my work about integrating OCaml and Qt. Initially, I planned to generate binding code for OCaml and Qt Widgets and called this library

. But I found it hard to implement mostly because Qt relies on inheritance very much (we can't add onClick handler for button without inheritance). Later I decided to generate binding code for OCaml and QML/QtQuick. And I believe that QtQuick is the right way to create UI in Qt right now. See online book for getting started with Qt/QML itself

From 14th of February 2017 it's renamed from

because it is actually about QtQuick and not QtWidgets or Qt itself. If you really need QtWidgets you can check out mrvn's work or def's.

Directories mapping:

  • PPX syntax extension with code generator is in
  • Library for interfacing with QtQuick 2 is in
  • Demo that can be build during opam installation is in
    . Use
    make demo
    to build it.
  • Old demos that are not using
    as build system are in
  • Demo app
    (ocamlbrowser with QtQuick instead of Tcl/Tk) is located in separate repo.

Github pages site and tutorial are available.


./configure && make
to build it. Don't forget to install
and good Qt version (>= 5.3 I think,
will check for it, btw).

Installed files

$ opam show lablqml --list-files

There is a library here. It's fine to use it for simple programs

There is also

executable. It is used to generate C++ code from OCaml. See
for examples

Minimal ocamlfind-based helloworld

➜  cat                                                                                                                     
open Lablqml

let main () = () let () = run_with_QQmlApplicationEngine Sys.argv main "Root.qml"

➜  cat Root.qml
import QtQuick 2.0
import QtQuick.Controls 1.0

ApplicationWindow { color: "#FFFFDF" // we declare rectangle with custom background color width: 400; height: 300; // with custom size Text { anchors.centerIn: parent text: "Click me!" } MouseArea { anchors.fill: parent // all space in parent Rectangle will be clickable } }

➜  ocamlfind opt -package lablqml -thread -linkpkg -cclib -lQt5Quick -cclib -lQt5Qml -cclib -lQt5Network -cclib -lQt5Widgets -cclib -lQt5Gui -cclib -lQt5Core -cclib -lstdc++
➜  ./a.out

Playing with REPL

#require "lablqml";;

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.