Skip to content

JuliaGraphics/QMLMakie.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QMLMakie

This is a Julia package for bridging Makie and Qt via QML.jl. It allows embedding hardware-accelerated interactive plots in Qt applications.

Quickstart

The following example simply shows the first lineplot example from the Makie documentation in a QML window. It uses the MakieArea QML component that is provided by QMLMakie.jl (obtained using import Makie in QML), and then sets the scene property of that component to the Makie figure, by passing it to a QML context property named plot. The MakieArea component is an extension of the MakieViewport from QML.jl, adding handling of the events so e.g. mouse controls work.

using GLMakie
using QMLMakie
using QML
QML.setGraphicsApi(QML.OpenGL)

# Data
seconds = 0:0.1:2
measurements = [8.2, 8.4, 6.3, 9.5, 9.1, 10.5, 8.6, 8.2, 10.5, 8.5, 7.2,
        8.8, 9.7, 10.8, 12.5, 11.6, 12.1, 12.1, 15.1, 14.7, 13.1]

# Makie plotting commands
fig = Figure()
ax = Axis(fig[1, 1],
    title = "Experimental data and exponential fit",
    xlabel = "Time (seconds)",
    ylabel = "Value",
)
scatter!(ax, seconds, measurements, color = :tomato)
lines!(ax, seconds, exp.(seconds) .+ 7, color = :tomato, linestyle = :dash)

# Build the QML interface and display the plot
mktemp() do qmlfile,_
  qml = """
  import QtQuick
  import QtQuick.Controls
  import QtQuick.Layouts
  import Makie

  ApplicationWindow {
    title: "Makie plot"
    visible: true
    width: 640
    height: 480

    MakieArea {
      anchors.fill: parent
      scene: plot
    }
  }
  """

  write(qmlfile, qml)
  loadqml(qmlfile; plot = fig)
  exec()
end

Features

  • All Makie events are linked to the corresponding events coming from QML
  • Proper support for scaled displays

About

Julia package integrating QML with Makie

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •