QML.jl first release

Hi all,

I am pleased to announce the first release of QML.jl, a package to interface with the Qt5 QML GUI toolkit. Feel free to try it out and leave feedback.

Main features

  • Standard mechanisms for exchanging data with the QML side, so all the QML widgets are available and can be fed with Julia data
  • Julia Display support, using PNG only for now (see plot.jl example)
  • ListModel to use Julia arrays as models for ListView and so on (see dynamiclist.jl example)
  • Support for ModernGL.jl (see gltriangle.jl example)
  • Preliminary (i.e. no mouse events in the viewport yet) support for GLVisualize.jl (see glvisualize.jl example)
  • Tested on Linux, macOS and Windows
  • The inherent QML features, including clean separation of GUI and backend and a high-quality native look.

Note, the easiest way to run the examples on Windows:

cd(Pkg.dir("QML"))
include("example\\gui.jl")

How it works

QML is accessed through some custom C++ classes that use the standard Qt5 C++ API and are exposed to Julia using CxxWrap.jl. In fact, the whole package started as a proof-of-concept for CxxWrap following this thread, but it got out of hand :wink:

Caveats

  • Fedora dependencies installation was broken in the tagged release, so you should do a Pkg.checkout or manually install qt:
    sudo yum install cmake qt5-qtbase-devel qt5-qtquickcontrols qt5-qtquickcontrols2-devel
  • There is a build error on Windows, but itā€™s a harmless typo and the package works after installation anyway
  • To run the glvisualize example, you need to checkout GLWindow after adding the GLVisualize package.
10 Likes

I just tried this on a ā€œcleanā€ Windows 7 machine, and it didnā€™t work because the Visual C++ Redistributable was missing. It can be installed from here:

@tkelman Would it be acceptable to distribute those DLLs with the CxxWrap binaries? The ā€œproperā€ way seems to use a merge module in the installer, but that is of course not applicable to a Julia package.

1 Like

Doesnā€™t Qt have a mingw build that would avoid these issues? Unless someoneā€™s paying you to care about visual studio, you should probably avoid it.

On Windows 10, mingw is no longer in the officially supported list:
http://doc.qt.io/qt-5/supported-platforms.html

Mingw would probably work anyway, but I prefer to avoid it:

  • Combined with CMake, Visual Studio is a much more pleasant experience on Windows than MinGW, not the least in terms of compilation speed (minor issue at the current project size)
  • VS is the standard development tool on Windows, it will be familiar to a much larger portion of the audience. Being able to use it to compile this package is more encouraging to get contributions
  • I was under the impression (could be wrong though?) that the largest portion of the Julia userbase is on Windows, so I prefer to put in a little effort to make the package usable for the largest part of the audience. In the end, itā€™s pretty easy to do with CMake
  • VS, for all its faults, gave valid compilation errors that both clang and gcc overlooked, so multi-compiler use improves the code
  • Appveyor works out of the box, all dependencies are installed and it can just compile and test both CxxWrap.jl and QML.jl. I donā€™t know if that also applies for mingw.

Finally, no, Iā€™m not paid for this, in fact the only time I use Windows for non-gaming activity is to test my packages and build their binaries :slight_smile:

MSVC is not supported for use with Julia. Its lack of required functionality for many scientific libraries is a strong argument against your first point. While it might work some of the time to use it in packages, youā€™re fighting against the way the language and almost every binary package that Iā€™m aware of is built. Mixing compiler runtimes is a bad idea. If you prefer MSVC, then you should work to make MSVC a supported platform for Julia itself before using it in packages. Thereā€™s a pretty clear path to improving that situation, but today it doesnā€™t exist as something users should touch. The issues related to this are extremely quiet, so if thereā€™s any demand in the Julia user community for better MSVC support weā€™re not seeing it.

The majority of Julia users are not C++ developers and very few of them have compilers installed at all (at least on Windows). Witness the pain that is building Python C extensions on Windows and the reason conda exists - all of that is toolchain inflicted.

Youā€™re right that itā€™s often a good idea to try building a code base with multiple compilers, but asking an open source community that primarily develops on Mac and Linux to support MSVC at all is painful and not worth their time. GCC at least works comparably everywhere, and developers can cross compile Windows binaries for their users without having to develop on Windows themselves.

Well, I think many people are very happy to get a powerful GUI solution for Julia, that works on the three major platforms. Most of them would probably donā€™t mind installing the VC++ redistributable, as long as it is clearly documented how to do that. Keep up the good work!

Uwe

3 Likes

Thanks :slight_smile:

I was holding off replying until I could test this, but hereā€™s what I found out / plan to do after some more research:

  • The redistributable DLLs could be placed in the zip archive, legally.
  • I understand there can be issues mixing binaries, but in this case it happens through a C interface and works well, as demonstrated by the passing tests on appveyor

On the other hand:

  • Julia binaries already ship with a libstdc++
  • Should others write CxxWrap-based packages and release on Windows, they are forced to use the same compiler as I do, to ensure binary compatibility with the CxxWrap releases.
  • MSYS2 has 64-bit Qt 5.6 binaries (those are missing from the official Qt installer, which is what prompted me to stick with MSVC I recall now)
  • Appveyor can also build using MSYS2 it seems, and most of the scripting boilerplate is in fact in the Julia source tree

So I plan to:

  • try building binaries with MSYS2 and the mingw version used by Julia (hopefully compatible with the MSYS2 Qt binaries)
  • update appveyor scripts so binaries are built there and can be uploaded automatically somewhere
  • keep the MSVC tests also, to ensure it still works when/if a MSVC Julia variant appears

The advantage of this approach is that anyone using QML.jl as a template for a CxxWrap-based project will also benefit from automatic binary generation on Windows, after some adaptations to the scripts, and doing so ensures binary compatibility across all CxxWrap-based packages.

Now letā€™s hope all of this will work :slight_smile:

The ā€˜holy grailā€™ of UI toolkits for interpreted/JIT compiled languages is a solution that works without further compilation/linking activities and without major installations. Something like this is available with toolkits/libraries that have simple+clear C-APIs (see ccall). With this background iā€™d rather call Gtk.jl a powerful GUI solution that works on ā€˜theā€™ three major platforms (minus rendering problems with Fonts or HiDPI).

Iā€™d not assume that everyone can simply install a VC++ redistributable in her/his Windows setup, even if she/he wants to.

Donā€™t get me wrong, iā€™d like to see QML or similar Qt based UI succeeding, but weā€™re importing too many dependencies with the current approach.

The VC++ redistributable is just a set of a few small DLLs that can be dropped into the QML binary folder and would be included in the binary download (transparent through Pkg.add). But like I said, this is no longer my preferred solution after @tkelman 's comments and some further research.

Thatā€™s simply not true: I forgot to add the VC++ redistributable DLLs for the current release, thatā€™s all. The ā€œmany dependenciesā€ consist of a single 36MB zip file that is downloaded automatically on Windows, or the required Qt packages on OS X or Linux (just like you need the Gtk packages for Gtk.jl). As mentioned in my previous post, I will attempt a MinGW solution since it is a cleaner fit for Julia, but in terms of dependencies the difference is negligible (the equivalent DLL is libstdc++.dll, and it comes with Julia).

Well, i might be missing something here, but QML.jl list CxxWrap.jl as requirement and that mentions:

Building on Windows

To build on Windows, you need to set the BUILD_ON_WINDOWS environment variable to ā€œ1ā€ in order to avoid the automatic binary download. The build prerequisites are:

Cmake in the path
Latest version of Visual Studio (Visual Studio 2015 Update 2 RC with MSVC 19.0.23824.1, it won't work on older versions due to internal compiler errors)

Aha, I see that line could use some extra clarification :slight_smile:

This is just needed if you want to compile CxxWrap (and QML) on Windows, but the default is to download binaries on Windows, and then you donā€™t need Visual Studio or CMake.