• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    OCaml
  • License
    GNU Lesser Genera...
  • Created over 13 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interfacing Qt/QML with OCaml. Formely known as lablqt

OCaml 4.10 on master

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 lablqt. 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 lablqt to lablqml 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 ppx/.
  • Library for interfacing with QtQuick 2 is in lib.
  • Demo that can be build during opam installation is in dune_test. Use make demo to build it.
  • Old demos that are not using dune as build system are in demos/.
  • Demo app qocamlbrowser (ocamlbrowser with QtQuick instead of Tcl/Tk) is located in separate repo.

Github pages site and tutorial are available.

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

Installed files

$ opam show lablqml --list-files
/home/kakadu/.opam/4.07.0+fp+flambda/bin/ppx_qt
/home/kakadu/.opam/4.07.0+fp+flambda/doc/lablqml/CHANGELOG
/home/kakadu/.opam/4.07.0+fp+flambda/doc/lablqml/README.md
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/META
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/dune-package
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.a
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.cma
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.cmi
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.cmt
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.cmti
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.cmx
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.cmxa
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.cmxs
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.h
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.ml
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/lablqml.mli
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/liblablqml_stubs.a
/home/kakadu/.opam/4.07.0+fp+flambda/lib/lablqml/opam
/home/kakadu/.opam/4.07.0+fp+flambda/lib/stublibs/dlllablqml_stubs.so

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

There is also ppx_qt executable. It is used to generate C++ code from OCaml. See demos/ for examples

Minimal ocamlfind-based helloworld

➜  cat a.ml
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 a.ml -thread -linkpkg -cclib -lQt5Quick -cclib -lQt5Qml -cclib -lQt5Network -cclib -lQt5Widgets -cclib -lQt5Gui -cclib -lQt5Core -cclib -lstdc++
➜  ./a.out

Playing with REPL

#thread;;
#require "lablqml";;

More Repositories

1

zanuda

OCaml linter
OCaml
63
star
2

camlyaml

YAML parser for OCaml
OCaml
11
star
3

fp2023

OCaml
11
star
4

Neznaju

Discontinued. Kate plugin for collaborated editing
C++
7
star
5

ocaml-neo4j

API to access Neo4j database via REST
OCaml
6
star
6

fp2022

OCaml
5
star
7

ocaml-pgn

Parser for chess Portable Game Format
OCaml
4
star
8

Falka

A tool for using fsyacc and parser-combinators together.
F#
4
star
9

ocaml-qt-android-demo

Hello world about lablqt: OCaml+Qt on Android
Makefile
4
star
10

LogicT-demos

Updated demos for a paper `Backtracking, Interleaving, and Terminating Monad Transformers`
Haskell
4
star
11

comp23hw

OCaml
3
star
12

ppx_gt

OCaml
3
star
13

qml-test-2

C++
3
star
14

QOcamlBrowser_quick

A clone of ocamlbrowser application written in OCaml+QtQuick 2.0 using lablqt library and mocml generator.
OCaml
3
star
15

proelium

Civilization III - like fighting model.
C++
3
star
16

osm-parser

an example for thedeemons article about parser combinators
OCaml
3
star
17

test-qml-jsoo

Demo for QtQuick and Js_of_ocaml integration.
Makefile
3
star
18

fastware

Some performance microbenchmarking for OCaml
OCaml
2
star
19

lama-compiler-2022

Homework as PR should go here.
2
star
20

kakadu.github.io

TeX
2
star
21

bitvector-mk

OCaml
2
star
22

bakmachine

Yet another virtual machine for a toy language
OCaml
2
star
23

OCanren-basic-template

A template repository for relational programming using OCanren
OCaml
2
star
24

Triss

Haxe IDE
OCaml
2
star
25

xcp-xapi

Sandpit for xcp-xapi from wheezy
OCaml
2
star
26

Qt_libusb

Qt GUI with libusb integration example.
C++
2
star
27

vcaml

Playground about symbolic interpreters
OCaml
2
star
28

klogic_of_ocanren

OCaml
1
star
29

ocanren-perf

Benchmarks for different miniKanren implementations
OCaml
1
star
30

BakmachineHS

Haskell
1
star
31

logger

Svn mirror of http://oops.math.spbu.ru/projects/logger/
OCaml
1
star
32

settings

Svn mirror of http://oops.math.spbu.ru/projects/settings/
OCaml
1
star
33

dune-demo-two-ppxes

OCaml
1
star
34

barbra

OCaml
1
star
35

Megaclops

Haskell
1
star
36

unicanren

OCaml
1
star
37

phil_asp

1
star
38

bigbro

Haxe
1
star
39

tarjan

Implementation of Tarjan's algotithm for OCamlGraph library
OCaml
1
star
40

sdl_ocaml_examples

OCaml
1
star
41

pp_sexp

Pretty-printing of s-expressions. Implemented in OCaml
OCaml
1
star
42

camloogle

Hoogle for OCaml using Ocsigen
1
star
43

qml-test

qml-test
C++
1
star
44

YEAPMM

Yet Another APM Meter
C++
1
star
45

ldd-2011

My practices on Linux Device Drivers course
C
1
star
46

checked

Svn mirror of http://oops.math.spbu.ru/projects/checked\/
OCaml
1
star
47

haskell-exam-arithm

Haskell
1
star
48

test-nix-ocaml

OCaml
1
star
49

obsidian-timelines-workout

TypeScript
1
star
50

typeutil

Svn mirror of http://oops.math.spbu.ru/projects/typeutil/
OCaml
1
star