qtscript: add example

This commit is contained in:
mappu 2024-11-26 19:55:26 +13:00
parent 2526335d5d
commit 10d01df372
2 changed files with 24 additions and 0 deletions

1
.gitignore vendored
View File

@ -33,6 +33,7 @@ examples/libraries/extras-scintillaedit/extras-scintillaedit
examples/libraries/qt-multimedia/qt-multimedia
examples/libraries/qt-network/qt-network
examples/libraries/qt-printsupport/qt-printsupport
examples/libraries/qt-script/qt-script
examples/libraries/qt-svg/qt-svg
examples/libraries/qt6-multimedia/qt6-multimedia
examples/libraries/restricted-extras-qscintilla/restricted-extras-qscintilla

View File

@ -0,0 +1,23 @@
package main
import (
"fmt"
"os"
"github.com/mappu/miqt/qt"
"github.com/mappu/miqt/qt/script"
)
func main() {
qt.NewQApplication(os.Args)
inputProgram := "1 + 2"
eng := script.NewQScriptEngine()
result := eng.Evaluate(inputProgram)
fmt.Printf("%s = %1.f\n", inputProgram, result.ToNumber())
// qt.QApplication_Exec()
}