2013-09-24 8 views

ответ

0

Этот пример иллюстрирует использование Qt/Qyoto

type MySpinner(parent : QWidget) = 
    inherit QSpinBox(parent) 
    override this.MouseReleaseEvent(e : QMouseEvent) = 
     base.MouseReleaseEvent(e) 
     printfn "spinner clicked! x: %i, y: %i" (e.X()) (e.Y()) 

type QyotoApp() as this = 
    inherit QWidget() 

    let button, label, layout, spinner = 
     new QPushButton("Count!", this), 
     new QLabel("Enter a value to count to:", this), 
     new QVBoxLayout(this), 
     new MySpinner(this) 

    do this.WindowTitle <- "F#/Qyoto Example" 
     this.ToolTip <- "This is a QWidget" 
     this.Resize(250, 75) 
     this.Move(300, 300) 
     layout.AddWidget(label) 
     layout.AddWidget(spinner) 
     layout.AddWidget(button) 
     button.Checkable <- true 
     spinner.SetRange(0, Int32.MaxValue) 
     QObject.Connect(button, QObject.SIGNAL("clicked(bool)"), 
      this, QObject.SLOT("ButtonClicked(bool)")) |> ignore 
     this.Show() 

    [<Q_SLOT>] 
    member this.ButtonClicked(toggled : bool) =  
     printfn "button checked: %b" toggled 
     List.iter (printfn "%i") [1 .. spinner.Value] 

[<EntryPoint>] 
let main (args : string[]) = 
    new QApplication(args) |> ignore 
    new QyotoApp() |> ignore 
    QApplication.Exec() 

Я рекомендую вам потратить некоторое время на изучение свой путь вокруг Qt в C++, прежде чем прыгать в Qyoto так как он не имеет официальной документации.

Смежные вопросы