GithubHelp home page GithubHelp logo

qml.jl's Introduction

QML

Latest CodeCov test

This package provides an interface to Qt6 QML (and to Qt5 for older versions). It uses the CxxWrap package to expose C++ classes. Current functionality allows interaction between QML and Julia using Observables, JuliaItemModels and function calling. There is also a generic Julia display, as well as specialized integration for image drawing, GR plots and Makie.

QML demo

Installation

Installation on Linux, Mac and Windows should be as easy as: (in pkg mode, hit ] in the Julia REPL):

add QML

Documentation

See https://JuliaGraphics.github.io/QML.jl/dev

Examples

A set of examples is available in the repository at https://github.com/barche/QmlJuliaExamples

Basic usage

Running examples

To run the examples, execute the following code block in the Julia REPL.

# Alternatively, execute the git command directly in the shell or download the zip file
import LibGit2
isdir("QmlJuliaExamples") || LibGit2.clone("https://github.com/barche/QmlJuliaExamples.git", "QmlJuliaExamples")
cd("QmlJuliaExamples/basic") # or images, opengl or plots instead of the basic subdirectory

# As an alternative to next three lines,
# 1) Start Julia with `julia --project`
# 2) Run `instantiate` from the pkg shell.
using Pkg
Pkg.activate(".")
Pkg.instantiate()

readdir() # Print list of example files
include("gui.jl") # Or any of the files in the directory

Loading a QML file

We support three methods of loading a QML file: QQmlApplicationEngine, QQuickView and QQmlComponent. These behave equivalently to the corresponding Qt classes.

QQmlApplicationEngine

The easiest way to run the QML file main.qml from the current directory is using the loadqml function, which will create and return a QQmlApplicationEngine and load the supplied QML file:

using QML
loadqml("main.qml")
exec()

The lifetime of the QQmlApplicationEngine is managed from C++ and it gets cleaned up when the application quits. This means it is not necessary to keep a reference to the engine to prevent it from being garbage collected prematurely.

QQuickView

The QQuickView creates a window, so it's not necessary to wrap the QML in ApplicationWindow. A QML file is loaded as follows:

qview = init_qquickview()
set_source(qview, "main.qml")
QML.show(qview)
exec()

QQmlComponent

Using QQmlComponent the QML code can be set from a Julia string wrapped in QByteArray:

qml_data = QByteArray("""
import ...

ApplicationWindow {
  ...
}
""")

qengine = init_qmlengine()
qcomp = QQmlComponent(qengine)
set_data(qcomp, qml_data, "")
create(qcomp, qmlcontext());

# Run the application
exec()

Interacting with Julia

Interaction with Julia happens through the following mechanisms:

  • Call Julia functions from QML
  • Read and set context properties from Julia and QML
  • Emit signals from Julia to QML
  • Use data models

Note that Julia slots appear missing, but they are not needed since it is possible to directly connect a Julia function to a QML signal in the QML code (see the QTimer example below).

Calling Julia functions

In Julia, functions are registered using the qmlfunction function:

my_function() = "Hello from Julia"
my_other_function(a, b) = "Hi from Julia"

qmlfunction("my_function", my_function)
qmlfunction("my_other_function", my_other_function)

For convenience, there is also a macro that registers any number of functions that are in scope and will have the same name in QML as in Julia:

@qmlfunction my_function my_other_function

However, the macro cannot be used in the case of non-exported functions from a different module or in case the function contains a ! character.

In QML, include the Julia API:

import org.julialang

Then call a Julia function in QML using:

Julia.my_function()
Julia.my_other_function(arg1, arg2)

Context properties

Context properties are set using the context object method. To dynamically add properties from Julia, a QQmlPropertyMap is used, setting e.g. a property named a:

propmap = QML.QQmlPropertyMap()
propmap["a"] = 1

This sets the QML context property named property_name to value julia_value.

The value of a property can be queried from Julia like this:

@test propmap["a"] == 1

To pass these properties to the QML side, the property map can be the second argument to loadqml:

loadqml(qml_file, propmap)

There is also a shorthand notation using keywords:

loadqml(qml_file, a=1, b=2)

This will create context properties a and b, initialized to 1 and 2.

Observable properties

When an Observable is set in a QQmlPropertyMap, bi-directional change notification is enabled. For example, using the Julia code:

using QML
using Observables

const qml_file = "observable.qml"
const input = Observable(1.0)
const output = Observable(0.0)

on(output) do x
  println("Output changed to ", x)
end

loadqml(qml_file, input=input, output=output)
exec_async() # run from REPL for async execution

In QML we add a slider for the input and display the output, which is twice the input (computed in QML here):

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

ApplicationWindow {
  id: root
  title: "Observables"
  width: 512
  height: 200
  visible: true

  ColumnLayout {
    spacing: 6
    anchors.fill: parent

    Slider {
      value: input
      Layout.alignment: Qt.AlignCenter
      Layout.fillWidth: true
      minimumValue: 0.0
      maximumValue: 100.0
      stepSize: 1.0
      tickmarksEnabled: true
      onValueChanged: {
        input = value;
        output = 2*input;
      }
    }

    Text {
      Layout.alignment: Qt.AlignCenter
      text: output
      font.pixelSize: 0.1*root.height
    }
  }

}

Moving the slider will print the output on Julia. The input can also be set from the REPL using e.g. input[] = 3.0, and the slider will move accordingly and call QML to compute the output, which can be queried using output[].

Type conversion

Most fundamental types are converted implicitly. Mind that the default integer type in QML corresponds to Int32 in Julia.

We also convert QVariantMap, exposing the indexing operator [] to access element by a string key. This mostly to deal with arguments passed to the QML append function in list models.

Emitting signals from Julia

Defining signals must be done in QML in the JuliaSignals block, following the instructions from the QML manual. Example signal with connection:

JuliaSignals {
  signal fizzBuzzFound(int fizzbuzzvalue)
  onFizzBuzzFound: lastFizzBuzz.text = fizzbuzzvalue
}

The above signal is emitted from Julia using simply:

@emit fizzBuzzFound(i)

There must never be more than one JuliaSignals block in QML

Using data models

JuliaItemModel

The JuliaItemModel type allows using data in QML views such as ListView and Repeater, providing a two-way synchronization of the data. The (now removed from Qt) dynamiclist example from Qt has been translated to Julia in the dynamiclist.jl example. As can be seen from this commit, the only required change was moving the model data from QML to Julia, otherwise the Qt-provided QML file is left unchanged.

A JuliaItemModel is constructed from a 1D Julia array. In Qt, each of the elements of a model has a series of roles, available as properties in the delegate that is used to display each item. The roles can be added using the addrole! function, for example:

julia_array = ["A", 1, 2.2]
myrole(x::AbstractString) = lowercase(x)
myrole(x::Number) = Int(round(x))

array_model = JuliaItemModel(julia_array)
addrole!(array_model, "myrole", myrole, setindex!)

adds the role named myrole to array_model, using the function myrole to access the value. The setindex! argument is a function used to set the value for that role from QML. This argument is optional, if it is not provided the role will be read-only. The arguments of this setter are collection, new_value, key as in the standard setindex! function.

To use the model from QML, it can be exposed as a context attribute, e.g:

loadqml(qml_file, array_model=array_model)

And then in QML:

ListView {
  width: 200
  height: 125
  model: array_model
  delegate: Text { text: myrole }
}

If no roles are added, the Qt::DisplayRole is exposed calling the Julia function string to convert whatever value in the array to a string.

In the dynamiclist example, the entries in the model are all "fruits", having the roles name, cost and attributes. In Julia, this can be encapsulated in a composite type:

mutable struct Fruit
  name::String
  cost::Float64
  attributes::JuliaItemModel
end

When an array composed only of Fruit elements is passed to a JuliaItemModel, setters and getters for the roles and the constructor are all passed to QML automatically, i.e. this will automatically expose the roles name, cost and attributes:

# Our initial data
fruitlist = [
  Fruit("Apple", 2.45, JuliaItemModel([Attribute("Core"), Attribute("Deciduous")])),
  Fruit("Banana", 1.95, JuliaItemModel([Attribute("Tropical"), Attribute("Seedless")])),
  Fruit("Cumquat", 3.25, JuliaItemModel([Attribute("Citrus")])),
  Fruit("Durian", 9.95, JuliaItemModel([Attribute("Tropical"), Attribute("Smelly")]))]

# Set a context property with our JuliaItemModel
propmap["fruitModel"] = JuliaItemModel(fruitlist)

See the full example for more details, including the addition of an extra constructor to deal with the nested JuliaItemModel for the attributes.

Using QTimer

QTimer can be used to simulate running Julia code in the background. Excerpts from basic/gui.jl:

const bg_counter = Observable(0)

function counter_slot()
  global bg_counter
  bg_counter[] += 1
end

@qmlfunction counter_slot

loadqml(qml_file, timer=QTimer(), bg_counter=bg_counter)

Use in QML like this:

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.julialang

ApplicationWindow {
    title: "My Application"
    width: 480
    height: 640
    visible: true

    Connections {
      target: timer
      onTimeout: Julia.counter_slot()
    }

    ColumnLayout {
      spacing: 6
      anchors.centerIn: parent

      Button {
          Layout.alignment: Qt.AlignCenter
          text: "Start counting"
          onClicked: timer.start()
      }

      Text {
          Layout.alignment: Qt.AlignCenter
          text: bg_counter.toString()
      }

      Button {
          Layout.alignment: Qt.AlignCenter
          text: "Stop counting"
          onClicked: timer.stop()
      }
  }
}

Note that QML provides the infrastructure to connect to the QTimer signal through the Connections item.

JuliaDisplay

QML.jl provides a custom QML type named JuliaDisplay that acts as a standard Julia multimedia Display. Currently, only the image/png mime type is supported. Example use in QML from the plot example:

JuliaDisplay {
  id: jdisp
  Layout.fillWidth: true
  Layout.fillHeight: true
  onHeightChanged: root.do_plot()
  onWidthChanged: root.do_plot()
}

The function do_plot is defined in the parent QML component and calls the Julia plotting routine, passing the display as an argument:

function do_plot()
{
  if(jdisp === null)
    return;

  Julia.plotsin(jdisp, jdisp.width, jdisp.height, amplitude.value, frequency.value);
}

Of course the display can also be added using pushdisplay!, but passing by value can be more convenient when defining multiple displays in QML.

JuliaCanvas

QML.jl provides a custom QML type named JuliaCanvas which presents a canvas to be painted via a julia callback function. This approach avoids the MIME content encoding overhead of the JuliaDisplay approach.

Example use in QML from the canvas example:

JuliaCanvas {
  id: circle_canvas
  paintFunction: paint_cfunction
  Layout.fillWidth: true
  Layout.fillHeight: true
  Layout.minimumWidth: 100
  Layout.minimumHeight: 100
}

The callback function paint_cfunction is defined in julia:

 function paint_circle(buffer::Array{UInt32, 1},
                      width32::Int32,
                      height32::Int32)
   width::Int = width32
   height::Int = height32
   buffer = reshape(buffer, width, height)
   buffer = reinterpret(ARGB32, buffer)
   paint_circle(buffer)
end

# callback to paint circle
function paint_circle(buffer)
   width, height = size(buffer)
   for x in 1:width
       for y in 1:height
           # paint here..., e.g.
           buffer[x,y] = ARGB32(1, 0, 0, 1) #red
       end
   end
end

loadqml(qmlfile,
        #...
        paint_cfunction = CxxWrap.@safe_cfunction(paint_circle, Cvoid, (Array{UInt32,1}, Int32, Int32))
)

Note that the canvas buffer is allocated (and freed) in the C++ code. A new unitialized buffer is allocated for each frame (this could change).

At the moment, only the 32-bit QImage::Format_RGB32 (alpha, red, green, blue) image format is supported.

See the example for details on emitting an update signal from julia to force redrawing the JuliaCanvas.


NOTE

Set

ENV["QSG_RENDER_LOOP"] = "basic"

at the top of your Julia file to avoid crashes or infinite loops when using JuliaCanvas.


Combination with the REPL

When launching the application using exec, execution in the REPL will block until the GUI is closed. If you want to continue using the REPL with an active QML gui, exec_async provides an alternative. This method keeps the REPL active and polls the QML interface periodically for events, using a timer in the Julia event loop. An example (requiring packages Plots.jl and PyPlot.jl) can be found in repl-background.jl, to be used as:

include("repl-background.jl")
plot([1,2],[3,4])

This should display the result of the plotting command in the QML window.

For further examples, see the documentation.

Breaking changes

Upgrade from v0.6 to v0.7

  • Julia 1.6 minimal requirement

Upgrade from v0.4 to v0.6

  • Signals in JuliaSignals must have arguments of type var
  • Role indices are 1-based now on the Julia side
  • The interface of some functions has changed because of the way CxxWrap handles references and pointers more strictly now
  • No more automatic conversion from String to QUrl, use the QUrl("mystring") constructor
  • Setting a QQmlPropertyMap as context object is not supported as of Qt 5.12

Upgrade from v0.6 to v0.8

This moves the package to Qt 6. Aside from this, the JuliaItemModel was changed extensively, refer to the test and examples to see how to use it.

qml.jl's People

Contributors

aminya avatar barche avatar bramtayl avatar cmey avatar giordano avatar hugo-trentesaux avatar jasha10 avatar leminaw avatar mkitti avatar nhdaly avatar pallharaldsson avatar samuelpowell avatar simondanisch avatar staticfloat avatar stemann avatar treygreer avatar ufechner avatar ufechner7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qml.jl's Issues

Calling unexported functions from QML

I'm having issues calling an unexported function from QML.
I have defined a function my_function in a module called PlugAndPlot.

I've tried both (I guess they are the same):

@qmlfunction PlugAndPlot.my_function

or

@qmlfunction my_function

and now in QML Julia.my_function thinks that my_function is undefined, whereas Julia.PlugAndPlot.my_function throws:

TypeError: Cannot call method 'my_function' of undefined

Is there a workaround other than exporting my_function?

Roadmap

This issue is for discussing the road map.
QML.jl is already working nice for me. I would suggest:

  1. Announce what we have once more on the mailing list. Ask people, to try it out and to create feature request tickets for what is missing.
  2. When someone is found, who has more time, then try to implement the features of the Ruby wrapper as documented here: http://www.rubydoc.info/github/seanchas116/ruby-qml/master/frames

From my point of view you need multi-threading for a good GUI application. This might become available with the 0.5 version of Julia. Until then I want to experiment with the multi tasking features of Julia.

Please add QML.jl to metadata.

I think, QML.jl has stabilized and should be added to metadata. It would be useful to have a tagged, stable release. :)

Pkg.build("QML") fails with error: โ€˜class cxx_wrap::ArrayRef<unsigned char>โ€™ has no member named โ€˜sizeโ€™

julia> Pkg.build("QML")
Running .juliarc.jl
INFO: Building CxxWrap
INFO: Building QML
INFO: Recompiling stale cache file /home/ufechner/.julia/lib/v0.4/CxxWrap.ji for module CxxWrap.
INFO: Attempting to Create directory /home/ufechner/.julia/v0.4/QML/deps/builds/qmlwrap
INFO: Changing Directory to /home/ufechner/.julia/v0.4/QML/deps/builds/qmlwrap
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ufechner/.julia/v0.4/QML/deps/builds/qmlwrap
Scanning dependencies of target qmlwrap_automoc
[ 12%] Automatic moc for target qmlwrap
Generating moc_julia_api.cpp
Generating moc_julia_display.cpp
Generating moc_julia_object.cpp
Generating moc_julia_signals.cpp
[ 12%] Built target qmlwrap_automoc
Scanning dependencies of target qmlwrap
[ 25%] Building CXX object CMakeFiles/qmlwrap.dir/julia_api.cpp.o
[ 37%] Building CXX object CMakeFiles/qmlwrap.dir/julia_display.cpp.o
/home/ufechner/.julia/v0.4/QML/deps/src/qmlwrap/julia_display.cpp: In member function โ€˜void qmlwrap::JuliaDisplay::load_png(cxx_wrap::ArrayRef)โ€™:
/home/ufechner/.julia/v0.4/QML/deps/src/qmlwrap/julia_display.cpp:23:47: error: โ€˜class cxx_wrap::ArrayRefโ€™ has no member named โ€˜sizeโ€™
if(!m_pixmap.loadFromData(data.data(), data.size(), "PNG"))
^
make[2]: *** [CMakeFiles/qmlwrap.dir/julia_display.cpp.o] Fehler 1
make[1]: *** [CMakeFiles/qmlwrap.dir/all] Fehler 2
make: *** [all] Fehler 2

Any idea?

exec() doesn't exit after QML error that prevents window from being displayed

First, thanks for a very useful package, it's helped me start building some GUI apps in Julia with minimal effort.

If there's an error in the QML that prevents the application window from being rendered, there's no way to close it, and exec() doesn't exit. I deal with this by stopping and starting Julia, which has some associated startup cost. Is there a better way to handle this, or have I missed something?

Update to Julia v0.7 or v1.0

Are there plans to update this package to the latest Version of Julia?

E.g. for the build.jl the function to determine the OS changed:

โ€ขThe operating system identification functions: is_linux, is_bsd, is_apple, is_unix, and is_windows, have been deprecated in favor of Sys.islinux, Sys.isbsd, Sys.isapple, Sys.isunix, and Sys.iswindows, respectively

Threading

Not really an issue, but a question: is there a way to use multiple threads with QML.jl? Either Julia threads or Qt ones? It is for the usual problems; i.e. computational process in background with responsive GUI in foreground.

Packages required by examples

Hello,

maybe we should find somewhere in doc all packages required by examples.

I personnally had to run:

Pkg.add("ModernGL")
Pkg.add("GLVisualize")
Pkg.add("GeometryTypes")
Pkg.add("GR")
Pkg.add("TestImages")
Pkg.add("QuartzImageIO")
Pkg.add("Plots")

to be able to run all examples.

I'm not sure where these kind of information should be written. But I'm just posting here as it may help some people also (to quickly run examples)

Kind regards

accessing properties in Julia from QML

I'm fairly new to gui programming and really miss something.

E.g. there is a QML element

Text {
            id: text1
            x: 179
            y: 155
            text: qsTr("Hello World!")
            font.pixelSize: 12
        }

How do I get or change the property text? Something like

@qmlget qmlcontext().text1.text

didn't work and it seems I miss some fundamental concept (and would expand the readme / a tutorial)

Integration of the GR Qt device driver

Great package!

I would like to directly access the QQuickPaintedItem instance within the GR Qt driver. This would allow me to use native Qt drawing commands instead of displaying a pre-rendered image, which is not fast enough.

Fur this purpose, the GR Qt driver needs access to the Qt drawable (widget) to obtain the width / height and the vertical / horizontal resolutions (logicalDpiX/Y). That latter is not absolutely necessary.

Right now, we encode the address of a given widget / painter in our applications into a "connection identifier", which is then passed to the GR driver using an environment variable (GKSconid). Would be great to get similar information from QML.jl - probably as a string containing those QObject pointers separated by "!" (%p!%p).

The width() and height() methods seem to be available for the QQuickPaintedItem - I will see how to avoid the logicalDpiX/Y methods, which don't seem to be available.

Error on example

I get the following error

ERROR: LoadError: LoadError: InitError: No ApplicationManager instance created
 in __init__() at C:\Users\John\.julia\v0.5\QML\src\QML.jl:32
 in include_from_node1(::String) at .\loading.jl:488
 in eval(::Module, ::Any) at .\boot.jl:234
 in require(::Symbol) at .\loading.jl:415
 in include_from_node1(::String) at .\loading.jl:488
during initialization of module QML
while loading C:\Users\John\.julia\v0.5\QML\src\QML.jl, in expression starting on line 481
while loading C:\Users\John\Dropbox\qmlgui.jl, in expression starting on line 2

when trying to run the repl_background example. Any tips?

Testing fails, if .julia.rc changes the current directory

My .julia.rc file contains:

cd("/home/ufechner/00PythonSoftware/FastSim")
push!(LOAD_PATH, pwd())

As a result, the following command fails:

julia> Pkg.test("QML")
INFO: Testing QML
Running .juliarc.jl
QQmlApplicationEngine failed to load component 
file:///mnt/ssd/ufechner/00PythonSoftware/FastSim/main.qml:-1 File not found

There must be a way to avoid this problem, but I could not find the solution yet.

Uwe

ArgumentError: TestImages not found in path

I tried the newest version.

This time I get a different error while running Pkg.test("QML"):

julia> Pkg.test("QML")
INFO: Testing QML
Running .juliarc.jl
Button was pressed 0 times
Background counter now at 0
qt_prefix_path() = "/home/ufechner/Qt/5.5/gcc_64"
ERROR: LoadError: LoadError: ArgumentError: TestImages not found in path
in require at ./loading.jl:233
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in process_options at ./client.jl:280
in _start at ./client.jl:378
while loading /home/ufechner/.julia/v0.4/QML/test/image.jl, in expression starting on line 3
while loading /home/ufechner/.julia/v0.4/QML/test/runtests.jl, in expression starting on line 7
=================================[ ERROR: QML ]=================================

failed process: Process(/usr/bin/julia --check-bounds=yes --code-coverage=none --color=yes /home/ufechner/.julia/v0.4/QML/test/runtests.jl, ProcessExited(1)) [1]

ERROR: QML had test errors
in error at ./error.jl:21
in test at pkg/entry.jl:803
in anonymous at pkg/dir.jl:31
in cd at file.jl:22
in cd at pkg/dir.jl:31
in test at pkg.jl:71

julia>

Any idea?

Error runing tests

INFO: Testing QML
ERROR: LoadError: LoadError: LoadError: could not load library "C:\j\.julia\v0.4\QML\deps\usr\lib\qmlwrap"
The specified module could not be found.

and indeed, in "C:\j.julia\v0.4\QML\deps\usr\lib" what have is a qmlwrap.lib instead of a qmlwrap.dll

How to deploy applications with QML?

An Application with Julia + QML is finished. What parts of Qt do I need to deploy the application on a seperate (e.g.) Windows System?

Is a whole Installation of the Qt Framework necessary or do I need only some dll?

error: call of overloaded โ€˜QVariant(long int)โ€™ is ambiguous

Hello,

this morning I get the following error:

(I already deleted cppwrapper and qml.jl and tried to reinstall them. The cppwrapper tests pass.)

INFO: Changing Directory to /home/ufechner/.julia/v0.4/QML/deps/builds/qml_wrapper
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ufechner/.julia/v0.4/QML/deps/builds/qml_wrapper
Scanning dependencies of target qml_wrapper_automoc
[ 33%] Automatic moc for target qml_wrapper
Generating moc_wrap_qml.cpp
[ 33%] Built target qml_wrapper_automoc
Scanning dependencies of target qml_wrapper
[ 66%] Building CXX object CMakeFiles/qml_wrapper.dir/wrap_qml.cpp.o
/home/ufechner/.julia/v0.4/QML/deps/src/qml_wrapper/wrap_qml.cpp: In instantiation of โ€˜QVariant qml_wrapper::detail::convert_to_qt(jl_value_t_) [with CppT = long int; jl_value_t = jl_value_t]โ€™:
/home/ufechner/.julia/v0.4/QML/deps/src/qml_wrapper/wrap_qml.cpp:30:50: required from โ€˜QVariant qml_wrapper::detail::try_convert_to_qt(jl_value_t
) [with TypesT = {double, long int, const char*}; jl_value_t = _jl_value_t]โ€™
/home/ufechner/.julia/v0.4/QML/deps/src/qml_wrapper/wrap_qml.cpp:42:61: required from here
/home/ufechner/.julia/v0.4/QML/deps/src/qml_wrapper/wrap_qml.cpp:20:59: error: call of overloaded โ€˜QVariant(long int)โ€™ is ambiguous
return QVariant(cpp_wrapper::convert_to_cpp(v));
^
/home/ufechner/.julia/v0.4/QML/deps/src/qml_wrapper/wrap_qml.cpp:20:59: note: candidates are:
In file included from /home/ufechner/Qt/5.5/gcc_64/include/QtCore/qlocale.h:37:0,
from /home/ufechner/Qt/5.5/gcc_64/include/QtGui/qguiapplication.h:40,
from /home/ufechner/Qt/5.5/gcc_64/include/QtWidgets/qapplication.h:45,
from /home/ufechner/Qt/5.5/gcc_64/include/QtWidgets/QApplication:1,
from /home/ufechner/.julia/v0.4/QML/deps/src/qml_wrapper/wrap_qml.cpp:3:
/home/ufechner/Qt/5.5/gcc_64/include/QtCore/qvariant.h:482:5: note: QVariant::QVariant(Qt::CursorShape)
QVariant(Qt::CursorShape) Q_DECL_EQ_DELETE;

"Directory already exists" error - Windows

I just updated QML.jl and it seems that it has some problems when the deps/usr directory already exists when updating. This may be a Windows-specific issue. I believe this same thing happened when I updated QML.jl some time ago (in December, maybe). The below describes the process after a failed Pkg.update() resulted in an obligatory Pkg.build("QML").

julia> Pkg.build("QML")
INFO: Building CxxWrap
Found Julia library at C:\Users\JohnRinehart\Programs\Julia-0.5.0\lib\libjulia.dll.a
INFO: Building QML
Using Qt from C:\Qt\5.7\msvc2015_64
INFO: Attempting to Create directory C:\Users\JohnRinehart\.julia\v0.5\QML\deps\downloads
INFO: Directory C:\Users\JohnRinehart\.julia\v0.5\QML\deps\downloads already created
INFO: Downloading file https://github.com/barche/QML.jl/releases/download/v0.3.0/QML-julia-0.5-win64.zip
INFO: Done downloading file https://github.com/barche/QML.jl/releases/download/v0.3.0/QML-julia-0.5-win64.zip
INFO: Attempting to Create directory C:\Users\JohnRinehart\.julia\v0.5\QML
INFO: Directory C:\Users\JohnRinehart\.julia\v0.5\QML already created
INFO: Path C:\Users\JohnRinehart\.julia\v0.5\QML\deps\usr already created
===================================================[ ERROR: QML ]====================================================

LoadError: Provider BinDeps.Binaries failed to satisfy dependency qmlwrap
while loading C:\Users\JohnRinehart\.julia\v0.5\QML\deps\build.jl, in expression starting on line 148

=====================================================================================================================

==================================================[ BUILD ERRORS ]===================================================

WARNING: QML had build errors.

 - packages with build errors remain installed in C:\Users\JohnRinehart\.julia\v0.5
 - build the package(s) and all dependencies with `Pkg.build("QML")`
 - build a single package by running its `deps/build.jl` script

=====================================================================================================================

Upon removing deps/usr:

julia> Pkg.build("QML")
INFO: Building CxxWrap
Found Julia library at C:\Users\JohnRinehart\Programs\Julia-0.5.0\lib\libjulia.dll.a
INFO: Building QML
Using Qt from C:\Qt\5.7\msvc2015_64
INFO: Attempting to Create directory C:\Users\JohnRinehart\.julia\v0.5\QML\deps\downloads
INFO: Directory C:\Users\JohnRinehart\.julia\v0.5\QML\deps\downloads already created
INFO: Downloading file https://github.com/barche/QML.jl/releases/download/v0.3.0/QML-julia-0.5-win64.zip
INFO: Done downloading file https://github.com/barche/QML.jl/releases/download/v0.3.0/QML-julia-0.5-win64.zip
INFO: Attempting to Create directory C:\Users\JohnRinehart\.julia\v0.5\QML
INFO: Directory C:\Users\JohnRinehart\.julia\v0.5\QML already created

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Processing archive: C:\Users\JohnRinehart\.julia\v0.5\QML\deps\downloads\QML-julia-0.5-win64.zip

Extracting  usr
Extracting  usr\lib
Extracting  usr\lib\bearer
Extracting  usr\lib\bearer\qgenericbearer.dll
Extracting  usr\lib\bearer\qnativewifibearer.dll
Extracting  usr\lib\D3Dcompiler_47.dll
Extracting  usr\lib\iconengines
Extracting  usr\lib\iconengines\qsvgicon.dll
Extracting  usr\lib\imageformats
Extracting  usr\lib\imageformats\qdds.dll
Extracting  usr\lib\imageformats\qgif.dll
Extracting  usr\lib\imageformats\qicns.dll
Extracting  usr\lib\imageformats\qico.dll
Extracting  usr\lib\imageformats\qjpeg.dll
Extracting  usr\lib\imageformats\qsvg.dll
Extracting  usr\lib\imageformats\qtga.dll
Extracting  usr\lib\imageformats\qtiff.dll
Extracting  usr\lib\imageformats\qwbmp.dll
Extracting  usr\lib\imageformats\qwebp.dll
Extracting  usr\lib\libEGL.dll
Extracting  usr\lib\libGLESV2.dll
Extracting  usr\lib\opengl32sw.dll
Extracting  usr\lib\platforminputcontexts
Extracting  usr\lib\platforminputcontexts\qtvirtualkeyboardplugin.dll
Extracting  usr\lib\platforms
Extracting  usr\lib\platforms\qwindows.dll
Extracting  usr\lib\private
Extracting  usr\lib\private\DropShadowBase.qml
Extracting  usr\lib\private\FastGlow.qml
Extracting  usr\lib\private\FastInnerShadow.qml
Extracting  usr\lib\private\FastMaskedBlur.qml
Extracting  usr\lib\private\GaussianDirectionalBlur.qml
Extracting  usr\lib\private\GaussianGlow.qml
Extracting  usr\lib\private\GaussianInnerShadow.qml
Extracting  usr\lib\private\GaussianMaskedBlur.qml
Extracting  usr\lib\private\qmldir
Extracting  usr\lib\private\qtgraphicaleffectsprivate.dll
Extracting  usr\lib\qmltooling
Extracting  usr\lib\qmltooling\qmldbg_debugger.dll
Extracting  usr\lib\qmltooling\qmldbg_inspector.dll
Extracting  usr\lib\qmltooling\qmldbg_local.dll
Extracting  usr\lib\qmltooling\qmldbg_native.dll
Extracting  usr\lib\qmltooling\qmldbg_profiler.dll
Extracting  usr\lib\qmltooling\qmldbg_quickprofiler.dll
Extracting  usr\lib\qmltooling\qmldbg_server.dll
Extracting  usr\lib\qmltooling\qmldbg_tcp.dll
Extracting  usr\lib\qmlwrap.dll
Extracting  usr\lib\qmlwrap.lib
Extracting  usr\lib\Qt5Core.dll
Extracting  usr\lib\Qt5Gui.dll
Extracting  usr\lib\Qt5Network.dll
Extracting  usr\lib\Qt5Qml.dll
Extracting  usr\lib\Qt5Quick.dll
Extracting  usr\lib\Qt5Svg.dll
Extracting  usr\lib\Qt5Widgets.dll
Extracting  usr\lib\QtGraphicalEffects
Extracting  usr\lib\QtGraphicalEffects\Blend.qml
Extracting  usr\lib\QtGraphicalEffects\BrightnessContrast.qml
Extracting  usr\lib\QtGraphicalEffects\Colorize.qml
Extracting  usr\lib\QtGraphicalEffects\ColorOverlay.qml
Extracting  usr\lib\QtGraphicalEffects\ConicalGradient.qml
Extracting  usr\lib\QtGraphicalEffects\Desaturate.qml
Extracting  usr\lib\QtGraphicalEffects\DirectionalBlur.qml
Extracting  usr\lib\QtGraphicalEffects\Displace.qml
Extracting  usr\lib\QtGraphicalEffects\DropShadow.qml
Extracting  usr\lib\QtGraphicalEffects\FastBlur.qml
Extracting  usr\lib\QtGraphicalEffects\GammaAdjust.qml
Extracting  usr\lib\QtGraphicalEffects\GaussianBlur.qml
Extracting  usr\lib\QtGraphicalEffects\Glow.qml
Extracting  usr\lib\QtGraphicalEffects\HueSaturation.qml
Extracting  usr\lib\QtGraphicalEffects\InnerShadow.qml
Extracting  usr\lib\QtGraphicalEffects\LevelAdjust.qml
Extracting  usr\lib\QtGraphicalEffects\LinearGradient.qml
Extracting  usr\lib\QtGraphicalEffects\MaskedBlur.qml
Extracting  usr\lib\QtGraphicalEffects\OpacityMask.qml
Extracting  usr\lib\QtGraphicalEffects\private
Extracting  usr\lib\QtGraphicalEffects\private\DropShadowBase.qml
Extracting  usr\lib\QtGraphicalEffects\private\FastGlow.qml
Extracting  usr\lib\QtGraphicalEffects\private\FastInnerShadow.qml
Extracting  usr\lib\QtGraphicalEffects\private\FastMaskedBlur.qml
Extracting  usr\lib\QtGraphicalEffects\private\GaussianDirectionalBlur.qml
Extracting  usr\lib\QtGraphicalEffects\private\GaussianGlow.qml
Extracting  usr\lib\QtGraphicalEffects\private\GaussianInnerShadow.qml
Extracting  usr\lib\QtGraphicalEffects\private\GaussianMaskedBlur.qml
Extracting  usr\lib\QtGraphicalEffects\private\qmldir
Extracting  usr\lib\QtGraphicalEffects\private\qtgraphicaleffectsprivate.dll
Extracting  usr\lib\QtGraphicalEffects\qmldir
Extracting  usr\lib\QtGraphicalEffects\qtgraphicaleffectsplugin.dll
Extracting  usr\lib\QtGraphicalEffects\RadialBlur.qml
Extracting  usr\lib\QtGraphicalEffects\RadialGradient.qml
Extracting  usr\lib\QtGraphicalEffects\RectangularGlow.qml
Extracting  usr\lib\QtGraphicalEffects\RecursiveBlur.qml
Extracting  usr\lib\QtGraphicalEffects\ThresholdMask.qml
Extracting  usr\lib\QtGraphicalEffects\ZoomBlur.qml
Extracting  usr\lib\QtQml
Extracting  usr\lib\QtQml\Models.2
Extracting  usr\lib\QtQml\Models.2\modelsplugin.dll
Extracting  usr\lib\QtQml\Models.2\plugins.qmltypes
Extracting  usr\lib\QtQml\Models.2\qmldir
Extracting  usr\lib\QtQuick
Extracting  usr\lib\QtQuick.2
Extracting  usr\lib\QtQuick.2\plugins.qmltypes
Extracting  usr\lib\QtQuick.2\qmldir
Extracting  usr\lib\QtQuick.2\qtquick2plugin.dll
Extracting  usr\lib\QtQuick\Controls
Extracting  usr\lib\QtQuick\Controls\plugins.qmltypes
Extracting  usr\lib\QtQuick\Controls\qmldir
Extracting  usr\lib\QtQuick\Controls\qtquickcontrolsplugin.dll
Extracting  usr\lib\QtQuick\Controls\Styles
Extracting  usr\lib\QtQuick\Controls\Styles\Flat
Extracting  usr\lib\QtQuick\Controls\Styles\Flat\qmldir
Extracting  usr\lib\QtQuick\Controls\Styles\Flat\qtquickextrasflatplugin.dll
Extracting  usr\lib\QtQuick\Controls\Styles\qmldir
Extracting  usr\lib\QtQuick\Extras
Extracting  usr\lib\QtQuick\Extras\plugins.qmltypes
Extracting  usr\lib\QtQuick\Extras\Private
Extracting  usr\lib\QtQuick\Extras\Private\CircularButton.qml
Extracting  usr\lib\QtQuick\Extras\Private\CircularButtonStyleHelper.qml
Extracting  usr\lib\QtQuick\Extras\Private\CircularTickmarkLabel.qml
Extracting  usr\lib\QtQuick\Extras\Private\Handle.qml
Extracting  usr\lib\QtQuick\Extras\Private\PieMenuIcon.qml
Extracting  usr\lib\QtQuick\Extras\Private\qmldir
Extracting  usr\lib\QtQuick\Extras\Private\TextSingleton.qml
Extracting  usr\lib\QtQuick\Extras\qmldir
Extracting  usr\lib\QtQuick\Extras\qtquickextrasplugin.dll
Extracting  usr\lib\QtQuick\Layouts
Extracting  usr\lib\QtQuick\Layouts\plugins.qmltypes
Extracting  usr\lib\QtQuick\Layouts\qmldir
Extracting  usr\lib\QtQuick\Layouts\qquicklayoutsplugin.dll
Extracting  usr\lib\QtQuick\PrivateWidgets
Extracting  usr\lib\QtQuick\PrivateWidgets\plugins.qmltypes
Extracting  usr\lib\QtQuick\PrivateWidgets\qmldir
Extracting  usr\lib\QtQuick\PrivateWidgets\widgetsplugin.dll
Extracting  usr\lib\QtQuick\Window.2
Extracting  usr\lib\QtQuick\Window.2\plugins.qmltypes
Extracting  usr\lib\QtQuick\Window.2\qmldir
Extracting  usr\lib\QtQuick\Window.2\windowplugin.dll
Extracting  usr\lib\scenegraph
Extracting  usr\lib\scenegraph\softwarecontext.dll
Extracting  usr\lib\translations
Extracting  usr\lib\translations\qt_ca.qm
Extracting  usr\lib\translations\qt_cs.qm
Extracting  usr\lib\translations\qt_de.qm
Extracting  usr\lib\translations\qt_en.qm
Extracting  usr\lib\translations\qt_fi.qm
Extracting  usr\lib\translations\qt_fr.qm
Extracting  usr\lib\translations\qt_he.qm
Extracting  usr\lib\translations\qt_hu.qm
Extracting  usr\lib\translations\qt_it.qm
Extracting  usr\lib\translations\qt_ja.qm
Extracting  usr\lib\translations\qt_ko.qm
Extracting  usr\lib\translations\qt_lv.qm
Extracting  usr\lib\translations\qt_pl.qm
Extracting  usr\lib\translations\qt_ru.qm
Extracting  usr\lib\translations\qt_sk.qm
Extracting  usr\lib\translations\qt_uk.qm

Everything is Ok

Folders: 25
Files: 131
Size:       60195110
Compressed: 22745653

SystemError: opening file /.../homebrew-core/Formula/qt5.rb: No such file or directory

I'm trying to build QML with JuliaPro 0.5.1.1 (under Mac OS 10.12.4 ) using

Pkg.build("QML")

and I get the following error message

===================================================================================[ ERROR: QML ]===================================================================================

LoadError: SystemError: opening file /Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/qt5.rb: No such file or directory
while loading /Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/QML/deps/build.jl, in expression starting on line 36

====================================================================================================================================================================================

==================================================================================[ BUILD ERRORS ]==================================================================================

WARNING: QML had build errors.

 - packages with build errors remain installed in /Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5
 - build the package(s) and all dependencies with `Pkg.build("QML")`
 - build a single package by running its `deps/build.jl` script

=

Looking for qt* in /Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/ directory

$ ls /Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/qt*
/Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/qt.rb
/Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/[email protected]
/Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/[email protected]
/Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/qtads.rb
/Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/qtfaststart.rb

Any idea?

apt-get can not install dependencies on Ubuntu 17.10

On ubuntu 17.10 I got:

E: Unable to locate package qtdeclarative5-dialogs-plugin
E: Unable to locate package qtdeclarative5-controls-plugin
E: Unable to locate package qtdeclarative5-quicklayouts-plugin

Those seem to be transitional packages, the corresponding new ones I needed to install were

sudo apt-get install qml-module-qtquick-controls qml-module-qtquick-dialogs

Of course I had to comment the apt-get line in the build.jl script to get the install process done.

Incompatible Julia vs QML filepath

More of a feature request than an issue. I'm trying to add a file dialog chooser to a qml app in julia and I encounter the following issue: QML can only give me the fileDialog.fileUrl which looks sth like:
file:///Users/...

It is a bit annoying to convert it to a Julia accepted filepath (as far as I understand I would need to remove file:// with 2 slashes for Mac OS and Linux and to remove file:/// with 3 slashes for it to work on Windows). It'd be nice to have a platform independent way to pass from one to the other.

wrong plot size in gr.jl example on a mac retina display

Not sure if it's a GR or a QML issue. On my machine (mac OS using built in retina display) when I run the example "gr.jl", the plot has the wrong size:

screen shot 2017-09-24 at 18 52 39

For it to be of a more appropriate size I need to manually change this line to

plt[:size] = (width(dev)/2, height(dev)/2)

screen shot 2017-09-24 at 18 52 07

I wonder if it's a bug with pixel doubling in retina display. I don't know how the plot would look like on another machine.

QML and canvas

Bonjour,

I've tried to run a canvas example from the site http://www.ics.com/blog/qml-canvas-element but it doesn't work.
Is it suppose to work?
(The julia script is the same from de QML.jl example)

-- Maurice

// Simple example of QML Canvas element
import QtQuick 2.0
// import org.julialang 1.0
Canvas {
    width: 400
    height: 400

    // JuliaContext {
    //   id: julia
    // }

    onPaint: {
        // Get drawing context
        var context = getContext("2d");

        // Make canvas all white
        context.beginPath();
        context.clearRect(0, 0, width, height);
        context.fill();

        // Fill inside with blue, leaving 10 pixel border
        context.beginPath();
        context.fillStyle = "blue"
        context.fillRect(10, 10, width - 20, height - 20);
        context.fill();

        // Draw a line
        context.beginPath();
        context.lineWidth = 2;
        context.moveTo(30, 30);
        context.strokeStyle = "red"
        context.lineTo(width-30, height-30);
        context.stroke();

        // Draw a circle
        context.beginPath();
        context.fillStyle = "orange"
        context.strokeStyle = "red"
        context.moveTo(width/2+60, height/2);
        context.arc(width/2, height/2, 60, 0, 2*Math.PI, true)
        context.fill();
        context.stroke();

        // Draw some text
        context.beginPath();
        context.strokeStyle = "lime green"
        context.font = "20px sans-serif";
        context.text("Hello, world!", width/2, 50);
        context.stroke();
    }
}

direct test of julia_signal.jl fails

Bonjour,

I got last snapshot of QML on osx 10.9.5.
When I go in the distrib QML/test directory, the following commands are working:

julia gui.jl
julia image.jl

But the following one does not: the test seems to work (no error) but doesn't show anything and quit immediately.

julia julia_signal.jl

-- Maurice
P.S: Thank you very much for this project, I'm not using it yet but I'm watching it and try the tests regularly .

Please provide forced (synchronous) redraw from Julia

I am building an application which triggers a Julia function that runs for several minutes and provides status updates as it goes. I want to show those updates in the GUI, but I have not found a way to get the Qt window redrawn before the Julia function returns. The objects I am aiming to update are Text objects and JuliaDisplay panels. All I see now is the final version of these. (I have tried interposing sleep() and readline() calls in Julia to yield to anything scheduled, and to calling the show() method of the ApplicationWindow from a signal, all to no avail.) For now, I would be content with some way to call into Qt to force a redraw with up-to-date object states. I am using Qt 5.7.1 on Linux, Julia 0.5 and QML 0.2.0.

Add docstrings to functions

The following functions need a docstring:

julia> using QML

help?> set_context_property
search: set_context_property

  No documentation found.

The same holds for the functions:
set_data, create, root_context, QML.exec, QML.application

can't load QML.jl after latest Pkg.update()

After the latest Pkg.update() QML.jl has a problem with CxxWrap (Pkg.checkout("CxxWrap") didn't help either).

julia> using QML
ERROR: LoadError: ccall: could not find function bind_module_constants in library /home/martin/.julia/v0.6/CxxWrap/deps/usr/lib/libcxx_wrap.so
Stacktrace:
 [1] wrap_module(::Ptr{Void}, ::Module) at /home/martin/.julia/v0.6/CxxWrap/src/CxxWrap.jl:305
 [2] wrap_module(::String, ::Module) at /home/martin/.julia/v0.6/CxxWrap/src/CxxWrap.jl:324
 [3] wrap_module(::String) at /home/martin/.julia/v0.6/CxxWrap/src/CxxWrap.jl:323
 [4] include_from_node1(::String) at ./loading.jl:532
 [5] eval(::Module, ::Any) at ./boot.jl:236
 [6] require(::Symbol) at ./loading.jl:446
while loading /home/martin/.julia/v0.6/QML/src/QML.jl, in expression starting on line 20

Julia is the latest v0.6-dev

Signals/slots

Hi Bart,

One thing I forgot to mention when we chatted at JuliaCon: I remember from your talk you discussed a signals/slots library for Julia. I'd encourage you to take a look at https://github.com/JuliaGizmos/Observables.jl as a potential candidate. It's the foundation for WebIO.jl, and @shashi has made it (or plans to make it) the base for both Juno and IJulia; I'm likely to provide a GtkObservables package similar to GtkReactive. One of the really cool things I just learned about @shashi's work is that he also has Javascript support for Observables, and he apparently has it set up so that "transport" between JS and Julia is minimized (if there are both JS and Julia listeners, then signals stay on the "side" that they start from whenever possible).

There may be future changes coming (see its issue 1), but apparently it's already working well for Shashi. There may be some merit in getting all the various GUI solutions using a common framework; if you're interested but want help, I'd be willing to pitch in as it would also give me an excuse to play with QML.

Use of QML in a module

Startup Time for my code is quite long, so i want to try to pack it all into a module and use __precompile__().

Somehow QML didn't recognize the functions used in julia which are exposed to QML through @qmlfunction. Neither if i export the function or call it with Julia.NuclideVector.decay_gui from QML (still @qmlfunction decay_gui of julia side).

It always results in TypeError: Cannot call method 'decay_gui' of undefined.

Is it even reasonable and possible to precompile a package with the use of QML?

edit: https://github.com/Ph0non/NuclideVector/tree/module

Allow to use Qt.labs.settings

Hello,
if I add the line:

import Qt.labs.settings 1.0

at the top of any .qml file I get the error message:

julia> include("gui.jl")
QQmlApplicationEngine failed to load component 
file:///home/ufechner/00Julia/QML.jl/example/qml/main.qml:5 module "Qt.labs.settings" is not installed

Being able to use this component would be very useful, because it automatically stores and restores the GUI properties.

Updating a TableView

Hi there, I am learning to use the TableView.
I am already able to load a QML table view with data from a julia array.
What I don't understand is how to push! an element to the julia array and then update/refresh the QML table view.
My qml and julia codes:

import QtQuick 2.3
import QtQuick.Controls 1.4
import QtQuick.Window 2.2
import QtQuick.Layouts 1.2
import org.julialang 1.0

ApplicationWindow {
    title: "Biometric Enroll"
    width: 1024
    height: 768
    visible: true

    menuBar: MenuBar {
        Menu {
            title: "File"
            MenuItem {
                text: "Login"
            }
            MenuItem {
                text: "Lock"
            }
            MenuItem {
                text: "Quit"
            }
        }
        Menu {
            title: "Enrolee"
            MenuItem {
                text: "Add a new Enrolee"
            }
            MenuItem {
                text: "Find by Name"
            }
            MenuItem {
                text: "Find by Birth"
            }
            MenuItem {
                text: "Find by Document"
            }
            MenuItem {
                text: "Find by Biographic"
            }
        }
        Menu {
            title: "Auth"
            MenuItem {
                text: "Verify Identity"
            }
            MenuItem {
                text: "Identify"
            }
            MenuItem {
                text: "Verify Relationship"
            }
        }
    }

    ColumnLayout {
        id: root
        spacing: 6
        anchors.fill: parent

        RowLayout {
            Layout.fillWidth: true
            Layout.alignment: Qt.AlignCenter

            Button {
                Layout.alignment: Qt.AlignCenter
                text: "Add column"
                onClicked: { Julia.append_enrolee() }
            }

            Button {
                Layout.alignment: Qt.AlignCenter
                text: "Remove column"
                onClicked: { Julia.pop_enrolee() }
            }
        }

        TableView {
            id: view
            Layout.fillWidth: true
            Layout.fillHeight: true
            model: enroleeModel

            TableViewColumn {
                id: nameColumn
                title: "Name"
                role: "name"
                width: 250
            }

            TableViewColumn {
                id: birthColumn
                title: "Birth"
                role: "birth"
                width: 120
            }

            TableViewColumn {
                id: parentColumn
                title: "Parent"
                role: "parent"
                width: 320
            }
        }
    }
}
using Base.Test
using QML

struct Enrolee
    name::String
    birth::String
    parent::String
end

enrolees = [Enrolee("rafael", "10/04/1990", "roger")]
enroleeModel = ListModel(enrolees)

function append_enrolee()
    println("tentando dar push!...")
    push!(enrolees, Enrolee("evandro", "10/04/1980", "roger"))
    enroleeModel = ListModel(enrolees)
end

function pop_enrolee()
    println("pressed pop year")
end

@qmlfunction append_enrolee pop_enrolee

# Load QML after setting context properties, to avoid errors on initialization
qml_file = joinpath(dirname(@__FILE__), "qml", "main.qml")
@qmlapp qml_file enroleeModel

# Run the application
exec()

println("Getting out.")

macOS Homebrew QT version error

I get the following error when building QML.jl

LoadError: SystemError: opening file /Users/spowell/.julia/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/qt5.rb: No such file or directory

Indeed, the only formulae available are qt.rb, [email protected], and [email protected], where the former refers to version 5.8. If I modify build.jl to ask Homebrew for qt, rather than qt5, the build works fine and all tests pass on 0.5.1.

Is this a problem with my local configuration, or is a PR required due to changes in Homebrew?

Compatibility with PyPlot

Hello,
I already built a nice GUI with QML.jl .
Now I want to use it together with PyPlot to plot the results. This fails:

julia> using QML

julia> using PyPlot
ERROR: InitError: PyError (:PyImport_ImportModule) <type 'exceptions.AttributeError'>
AttributeError("'module' object has no attribute 'new_figure_manager'",)
  File "/home/ufechner/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 114, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/ufechner/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 35, in pylab_setup
    new_figure_manager = backend_mod.new_figure_manager

 [inlined code] from /home/ufechner/.julia/v0.4/PyCall/src/exception.jl:81
 in pyimport at /home/ufechner/.julia/v0.4/PyCall/src/PyCall.jl:285
 in __init__ at /home/ufechner/.julia/v0.4/PyPlot/src/PyPlot.jl:264
 in _require_from_serialized at loading.jl:84
 in _require_from_serialized at ./loading.jl:109
 in require at ./loading.jl:219
during initialization of module PyPlot

julia> 

I know that it might be difficult to get this right. Is there a way to make PyPlot and QML compatible?

Please add a description to the repository

Suggestion:
"Julia/ C++ wrapper for graphical user interfaces, implemented in QML. QML (Qt Meta Language) is a user interface markup language similar to JavaScript."

plot.jl gives segfault when selecting GR backend

julia> include(joinpath(Pkg.dir("QML"),"example","plot.jl"))

signal (11): Segmentation fault
while loading /home/kjwiik/.julia/v0.5/QML/example/plot.jl, in expression starting on line 45
__libc_siglongjmp at /build/glibc-Qz8a69/glibc-2.23/setjmp/longjmp.c:30
unknown function (ip: 0x7f6d607c0fe1)
png_error at /usr/lib/x86_64-linux-gnu/libpng12.so.0 (unknown line)
png_create_write_struct_2 at /usr/lib/x86_64-linux-gnu/libpng12.so.0 (unknown line)
png_create_write_struct at /usr/lib/x86_64-linux-gnu/libpng12.so.0 (unknown line)
unknown function (ip: 0x7f6d607c118e)
cairo_surface_write_to_png at /home/kjwiik/.julia/v0.5/GR/src/../deps/gr/lib/./cairoplugin.so (unknown line)
unknown function (ip: 0x7f6d60761387)
gks_cairoplugin at /home/kjwiik/.julia/v0.5/GR/src/../deps/gr/lib/./cairoplugin.so (unknown line)
unknown function (ip: 0x7f6d60e9ba59)
gks_close_ws at /home/kjwiik/.julia/v0.5/GR/src/../deps/gr/lib/libGR.so (unknown line)
gks_emergency_close at /home/kjwiik/.julia/v0.5/GR/src/../deps/gr/lib/libGR.so (unknown line)
gr_emergencyclosegks at /home/kjwiik/.julia/v0.5/GR/src/../deps/gr/lib/libGR.so (unknown line)
_show at /home/kjwiik/.julia/v0.5/Plots/src/backends/gr.jl:1090
display at /home/kjwiik/.julia/v0.5/QML/src/QML.jl:111
unknown function (ip: 0x7f6d91820bd6)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:189 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1942
plotsin at /home/kjwiik/.julia/v0.5/QML/example/plot.jl:33
unknown function (ip: 0x7f6d917d1a92)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:189 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1942
jl_apply at /home/centos/buildbot/slave/package_tarball64/build/src/julia.h:1392 [inlined]
jl_call at /home/centos/buildbot/slave/package_tarball64/build/src/jlapi.c:126
_ZN7qmlwrap8JuliaAPI4callERK7QStringRK5QListI8QVariantE at /home/kjwiik/.julia/v0.5/QML/deps/usr/lib/libqmlwrap.so (unknown line)
unknown function (ip: 0x7f6d90f76405)
_ZN7qmlwrap8JuliaAPI11qt_metacallEN11QMetaObject4CallEiPPv at /home/kjwiik/.julia/v0.5/QML/deps/usr/lib/libqmlwrap.so (unknown line)
unknown function (ip: 0x7f6d902c1318)
unknown function (ip: 0x7f6d9024667b)
unknown function (ip: 0x7f6d90247ebb)
_ZN3QV413QObjectMethod12callInternalEPNS_8CallDataE at /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5 (unknown line)
_ZN3QV47Runtime12callPropertyEPNS_15ExecutionEngineEiPNS_8CallDataE at /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5 (unknown line)
unknown function (ip: 0x7f6d68024afc)
unknown function (ip: 0x7f6d901fef36)
unknown function (ip: 0xb56d51471f3b2bff)
Allocations: 18685626 (Pool: 18683953; Big: 1673); GC: 33
Segmentation fault (core dumped)
`

some more details on use of setindex! in ListModels

With interest i read your explainations in https://github.com/barche/QML.jl#listmodel and to change data in a ListModel from QML itself. This is exactly what i need for a new feature for my own code.

For editing a TableView i use code from stackoverflow which works fine (see here). This returns (with no surprise) Null setter for role "2016", not changing value because it is only readable.

Like in your example I added setindex! to addrole

addrole(nuclidesModel, year, n -> round(n.values[i],2), setindex!)

(see here and here)

But obviously i miss something, because this results in a segfault

ErrorException("type Float64 has no field values")

Windows build

I tried to build QML with an existing Qt5 installation. This works fine on macOS X and Ubuntu, but it fails on Windows 10. The QT_ROOT setting seems to be ignored during the build step. In our case, I wanted to use an existing Qt5 distribution located in S:\Qt\5.7.0. What is the trick?

Cannot create platform OpenGL context

Running a QML app with a window fails with:

QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
Failed to create OpenGL context for format QSurfaceFormat(version 3.3, options QFlags(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 1, profile  1) 

See https://discourse.julialang.org/t/board-game-interface-which-library/4221/5?u=barche

Crash on exit when running Pkg.test("QML")

Hello,

with the newest version of QML.jl I get a crash-on-exit when running the tests on Ubuntu 14.04.

julia> versioninfo()
Julia Version 0.4.5
Commit 2ac304d (2016-03-18 00:58 UTC)
Platform Info:
System: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
WORD_SIZE: 64
BLAS: libopenblas (NO_AFFINITY SANDYBRIDGE)
LAPACK: liblapack.so.3
LIBM: libopenlibm
LLVM: libLLVM-3.3

Any idea?

julia> Pkg.test("QML")
INFO: Testing QML
Button was pressed 3 times
Background counter now at 4435
qt_prefix_path() = "/home/ufechner/Qt/5.5/gcc_64"
*** Error in `/usr/bin/julia': free(): invalid pointer: 0x00007f3b9c2d5040 ***

signal (6): Aborted
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7f3dac802394)
unknown function (ip: 0x7f3dac80e66e)
unknown function (ip: 0x7f3b9adca290)
_ZN3QV413MemoryManager5sweepEb at /home/ufechner/Qt/5.5/gcc_64/lib/libQt5Qml.so.5 (unknown line)
_ZN3QV413MemoryManagerD2Ev at /home/ufechner/Qt/5.5/gcc_64/lib/libQt5Qml.so.5 (unknown line)
_ZN3QV415ExecutionEngineD1Ev at /home/ufechner/Qt/5.5/gcc_64/lib/libQt5Qml.so.5 (unknown line)
_ZN9QV8EngineD1Ev at /home/ufechner/Qt/5.5/gcc_64/lib/libQt5Qml.so.5 (unknown line)
_ZN9QV8EngineD0Ev at /home/ufechner/Qt/5.5/gcc_64/lib/libQt5Qml.so.5 (unknown line)
_ZN9QJSEngineD1Ev at /home/ufechner/Qt/5.5/gcc_64/lib/libQt5Qml.so.5 (unknown line)
_ZN10QQmlEngineD1Ev at /home/ufechner/Qt/5.5/gcc_64/lib/libQt5Qml.so.5 (unknown line)
_ZN21QQmlApplicationEngineD0Ev at /home/ufechner/Qt/5.5/gcc_64/lib/libQt5Qml.so.5 (unknown line)
_ZN8cxx_wrap6detail17finalizer_closureI21QQmlApplicationEngineEEP11_jl_value_tS4_PS4_j at /home/ufechner/.julia/v0.4/QML/deps/usr/lib/libqmlwrap.so (unknown line)
unknown function (ip: 0x7f3dacec159f)
unknown function (ip: 0x7f3dacec741c)
jl_atexit_hook at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
unknown function (ip: 0x4016e8)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x401725)
unknown function (ip: (nil))

Problem with window size on HighDPI displays

How can I easily obtain the devicePixelRatio from QML?

import QtQuick 2.0
import QtQuick.Window 2.2

ApplicationWindow {
        ... Screen.devicePixelRatio    // <== need this in Julia
    }
}

Background: when using QML + GR, the value for painter->device()->devicePixelRatio(), which is needed in the GR Qt driver, is always 1, even on Retina displays. This is probably due to the fact, a CoreProfile is selected for the QSurfaceFormat in QML's application manager. OpenGL always uses raster graphics (http://doc.qt.io/qt-5/highdpi.html).

However, the value that can be obtained within QML is correct. Is there something like a get_property() function to access that value from Julia?

Installing from 0.5 fails

Because its looking for a QML-julia-0.5-win64.zip that does not exist. Only a QML-julia-0.4-win64.zip

INFO: Building QML
INFO: Attempting to Create directory C:\j\.julia\v0.5\QML\deps\downloads
INFO: Directory C:\j\.julia\v0.5\QML\deps\downloads already created
INFO: Downloading file https://github.com/barche/QML.jl/releases/download/v0.1.0/QML-julia-0.5-win64.zip
Exception calling "DownloadFile" with "2" argument(s): "The request was aborted: The connection was closed unexpectedly."
At line:1 char:1
+ (new-object net.webclient).DownloadFile("https://github.com/barche/QM ...
+ 

Issue with SDK file path after High Sierra update

I tried to build QML after updating MacOS to High Sierra and I got a build error that seems to be related to the following warning:

INFO: Changing Directory to /Users/crashburnrepeat/.julia/v0.6/QML/deps/builds/qmlwrap
CMake Warning at /Users/crashburnrepeat/.julia/v0.6/Homebrew/deps/usr/Cellar/cmake/3.10.0/share/cmake/Modules/Platform/Darwin-Initialize.cmake:121 (message):
  Ignoring CMAKE_OSX_SYSROOT value:

   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk

  because the directory does not exist.

Manually changing the value in the CMakeCache.txt file to MacOSX10.13.sdk, this warning disappears and the package builds properly. Since MacOSX10.13.sdk seems to be a symbolic link to MacOSX.sdk, QML also builds correctly when that is the set path. Is there a reason why the OS version is kept cache like this, and why it isn't updated when QML detects that it's no longer a valid path? Might it be easier just to reference the version-less sdk location?

ListModel of 2D arrays

I understand the dynamic list example quite well to create dynamic lists on my own. But is it also possible the use an 2D array und use the QML TabView?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.