小编MHO*_*OOO的帖子

如何与Qt Jambi一起使用Clojure REPL?

我还没有找到在网上使用Clojure REPL和Qt 的解决方案.基本上问题是,只要您调用QApplication/exec以便显示UI,REPL就会挂起.你不能将Cc Cc重新放回REPL,关闭活动的Qt窗口似乎会杀死整个Clojure进程.

现在只能在代理中调用QApplication/processEvents是不可能的,除非代理运行在您创建Qt小部件的完全相同的线程中.我花了两天时间搞清楚这一点,我看到其他人有同样的问题/问题,但没有解决方案.所以这是我的,在代码中:

(add-classpath "file:///usr/share/java/qtjambi.jar")
(ns qt4-demo
  (:import (com.trolltech.qt.gui QApplication QPushButton QFont QFont$Weight)
           (com.trolltech.qt.core QCoreApplication)
           (java.util Timer TimerTask)
           (java.util.concurrent ScheduledThreadPoolExecutor TimeUnit))
  (:require swank.core))

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

(def *gui-thread* (new java.util.concurrent.ScheduledThreadPoolExecutor 1))
(def *gui-update-task* nil)
(def *app* (ref nil))

(defn update-gui []
  (println "Updating GUI")
  (QApplication/processEvents))

(defn exec []
  (.remove *gui-thread* update-gui)
  (def *gui-update-task* (.scheduleAtFixedRate *gui-thread* update-gui 0 150 (. TimeUnit MILLISECONDS))))

(defn stop []
  (.remove *gui-thread* update-gui)
  (.cancel *gui-update-task*))

(defmacro qt4 [& …
Run Code Online (Sandbox Code Playgroud)

lisp qt clojure qt-jambi read-eval-print-loop

11
推荐指数
1
解决办法
2092
查看次数

标签 统计

clojure ×1

lisp ×1

qt ×1

qt-jambi ×1

read-eval-print-loop ×1