Re: [LAD] Looking for an introduction to rt programming with a gui

From: Niels Mayer <nielsmayer@email-addr-hidden>
Date: Fri May 21 2010 - 01:18:52 EEST

I forgot to mention one of my main finds regarding clojure -- a nice Qt
interface, and working well w/ multithreaded...

http://tealeg.blogspot.com/2008/11/on-clojure-part-3-designer-uis-and.html
http://briancarper.net/blog/clojure-qt4-system-tray-mail-checker

As you'd expect from Clojure, the concurrency part of the app was a
> no-brainer. There are a bunch of threads hammering on a single global hash
> list of email messages, and they're all forcing updates of the GUI, but
> throw a bunch of dosync's around certain bits of code and it all works
> without worry. (Qt's invokeLater is also necessary if you're updating a Qt
> GUI from more than one thread at a time.)

> My first version of this app had even more threads, with one thread
> updating the GUI every few seconds, and another master thread managing all
> the mail threads. It also worked fine. It was overkill so I scaled it down,
> but it's really nice how you can coordinate a bunch of threads and don't
> have to worry about deadlocks and race conditions and whether your data
> structures are thread-safe.

Question: how easy is it to "add on" to an existing Qt/QtDesigner-based app
like, say, qtractor, the aforementioned clojure language extension?
(instead of "angelscript" mentioned in Rui's 0.1 whitepaper pdf... and
that's assuming the caveat mentioned in one of the above links "You must use
Qt Designer with the QtJambi plugins installed.") And how much would java be
able to "introspect" out of the C++/Qt-part of its environment without
having to be told about it. (e.g to access&manipulate, then schedule
rerendering of MIDI, timing, & non-destructive editing data.). The "slot"
stuff looks pretty introspective inter-call between QtDesigner and clojure
(from first link):

(gen-and-load-class "foo.gen.Slot"
      :methods [["slot" [] Void]])

(ns foo
  (:import (foo Ui_MainWindow))
  (:import (com.trolltech.qt.gui QApplication QMainWindow))
  (:import (com.trolltech.qt.core QCoreApplication))
  (:import (foo.gen Slot)))

(def slots
     (proxy [Slot] []
  (slot [] (prn "Slot Called"))))

(defn init []
  (QApplication/initialize (make-array String 0)))

(defn exec []
  (QApplication/exec))

(defmacro qt4 [& rest]
  `(do
     (try (init) (catch RuntimeException e# (println e#)))
     ~@rest
     (exec)))

(def Foo-main
  (fn [& args]
    (qt4
     (let [ui_main (new Ui_MainWindow)
    mainWindow (new QMainWindow)]
       (. ui_main (setupUi mainWindow))
       (let [pushButton (. ui_main pushButton)]
  (.. pushButton clicked (connect slots "slot()")))
       (. mainWindow (show))))))

Niels
http://nielsmayer.com

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Fri May 21 04:15:01 2010

This archive was generated by hypermail 2.1.8 : Fri May 21 2010 - 04:15:01 EEST