jverzani / PySide.jl

julia interface for accessing Qt via PyCall and PySide
MIT License
18 stars 6 forks source link

checkBox callback #7

Closed sam81 closed 10 years ago

sam81 commented 10 years ago

Not sure this is an issue with PySide or I'm not using qconnect the right way, but I'm unable to trigger a callback in the following example

using PySide            

function helloCheckBoxChanged()
    state = helloCheckBox[:isChecked]()
    println(state)
end

w = Qt.QWidget()        # constructors
w[:setWindowTitle]("Hello world example") 
lyt = Qt.QVBoxLayout(w)
w[:setLayout](lyt)

helloCheckBox = Qt.QCheckBox("Hello")
lyt[:addWidget](helloCheckBox)
qconnect(helloCheckBox, :stateChanged, (int) -> helloCheckBoxChanged)

raise(w)           

I'm on julia Version 0.3.0-prerelease+510, Commit 12b8a32 on Debian testing

jverzani commented 10 years ago

You just need to call the function in the handler: (int) -> helloCheckBoxChanged()). As an aside, if you call the argument state, then you can check it directly along the lines of state == int(qt_enum("Checked"))).

sam81 commented 10 years ago

great, thanks!