Makie render function not called
veddox opened this issue · comments
I'm struggling getting the Makie integration to work. Although I can run the two examples (makie.jl
and makie-plot.jl
) just fine, my own code only gives me a blank window:
using CxxWrap
using Observables
using QML
using GLMakie
using FileIO
using Persefone
ENV["QSG_RENDER_LOOP"] = "basic"
QML.setGraphicsApi(QML.OpenGL)
global model = initialise()
function render_map(screen)
global model
println("Updating map")
figure = visualisemap(model)
display(screen, figure.scene)
end
qmlfile = joinpath(dirname(@__FILE__), "mwe.qml")
loadqml(qmlfile,
render_map_callback = @safe_cfunction(render_map,Cvoid,(Any,)))
println("Launched MWE.")
exec()
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.julialang
ApplicationWindow {
id: makieWindow
title: "Makie integration"
width: 1024
height: 768
visible: true
MakieViewport {
id: mapviewport
Layout.fillWidth: true
Layout.fillHeight: true
renderFunction: render_map_callback
Component.onCompleted: {
mapviewport.update()
}
}
}
visualisemap()
is a function that returns a Makie figure; if I call this directly, GLMakie plots it as expected.
My output shows no errors, simply an empty window. As I do not see the "Updating map" debug statement printed, I assume the render function is never called.
I'm using the main branch of QML.jl
, GLMakie
0.6.13 and Makie
0.17.13
The problem here is with the QML, in the makie example we use a ColumnLayout
, hence the Layout.
options make sense there. Without a layout, you should use the anchors:
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.julialang
ApplicationWindow {
id: makieWindow
title: "Makie integration"
width: 1024
height: 768
visible: true
MakieViewport {
id: mapviewport
anchors.fill: parent
renderFunction: render_map_callback
}
}
Ref: https://doc.qt.io/qt-6.5/qtquick-positioning-anchors.html
Ah, that was it! I had eventually figured out that it must be something to do with layouts, but didn't know enough to understand what. Thanks for the pointer!