«FSharp, Qyoto on OS X

Posted on November 1, 2012

After playing around with MonoMac I realized most people I know are running windows, most of the time thats fine. But sometimes I’d like to show something off and Qyoto seems like it could be the perfect cross platform solution!

Warning, before I go on. I’m quite new to F# and Qt so if theres any errors give me a yell below

I got a bit stuck going through the whole process of setting everything up, so here’s what I did for anyone else looking to play with it.

Compiling Mono

The mono packages for OS X are 32bit, where as the Qt libraries from homebrew are 64bit. So based on adamv’s homebrew alt repo I made a mono3 recipe at aktowns/tappedbrews to install simply tap it and brew install.

brew tap aktowns/tappedbrews
brew install aktowns/tappedbrews/mono3

This will install mono 3.0.0 and FSharp 3.0.11 64bit, next we need Qt and Qyoto

Getting Qt and compiling Qyoto

If anyone knows how to imply –HEAD using depends_on in a recipe please tell me!
These homebrew recipes are mostly based off the instructions here with a few minor changes.

brew install qt
brew install aktowns/tappedbrews/smokegen --HEAD
brew install aktowns/tappedbrews/smokeqt --HEAD
brew install aktowns/tappedbrews/qyoto --HEAD

Installing monodevelop

Instead of compiling monodevelop, gtk# and numerous other dependencies its probably a lot easier to just grab the monodevelop binaries, install them and install mono 2.10.9 (to run monodevelop in) and select your default runtime as our brew compiled mono.


I noticed a bug with monodevelop (at least on where if you have the binary 3.0.0 and your brew compiled 3.0.0 monodevelop wont let you set the default (it keeps defaulting to the binary 3.0.0) so for now 2.10.9 is fine.

Now lets create a new F# console project!

An example F# Qyoto Application

Adapted from zetcode’s c# qyoto introduction

module Program

open System
open Qyoto

let SLOT = QWidget.SLOT

type QyotoApp() as self = class
  inherit QWidget()
    base.WindowTitle <- "Hello World!"
    base.ToolTip <- "Goodbye World"
    self.resizeAndCenter 250 150
  member self.resizeAndCenter w h =
    let qdw = new QDesktopWidget()
    let x = (qdw.Width - w) / 2
    let y = (qdw.Height - h) / 2
    base.Resize(w, h)
    base.Move(x, y)
  member self.setupButton : unit =
    let quit = new QPushButton("Quit", self)    
    self.Connect(quit, SIGNAL("clicked()"), SLOT("quit()")) |> ignore
    quit.SetGeometry(50, 40, 80, 30)
  // MARK: Slots
  member self.quit() : unit = Environment.Exit(0)

let main(args) : unit =    
    let application = new QApplication(args)
    let qyotoApp = new QyotoApp()
    QApplication.Exec() |> ignore

hello world
hello world