diff --git a/.gitignore b/.gitignore index 8612113f..2e87edd7 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ examples/mdoutliner/mdoutliner6 examples/windowsmanifest/windowsmanifest examples/uidesigner/uidesigner examples/trivialwizard6/trivialwizard6 +examples/subclass/subclass examples/libraries/extras-scintillaedit/extras-scintillaedit examples/libraries/qt-multimedia/qt-multimedia examples/libraries/qt-network/qt-network diff --git a/examples/subclass/main.go b/examples/subclass/main.go new file mode 100644 index 00000000..79f25200 --- /dev/null +++ b/examples/subclass/main.go @@ -0,0 +1,37 @@ +package main + +import ( + "os" + + "github.com/mappu/miqt/qt" +) + +func main() { + + qt.NewQApplication(os.Args) + + widget := qt.NewQWidget2() + widget.SetFixedWidth(320) + widget.SetFixedHeight(240) + + widget.OnPaintEvent(func(ev *qt.QPaintEvent) { + panic("xyz") + + ptr := qt.NewQPainter2(widget.QPaintDevice) + defer ptr.Delete() + + br := qt.NewQBrush12(qt.Black, qt.SolidPattern) + defer br.Delete() + + ptr.SetBrush(br) + + ptr.DrawRect2(80, 60, 160, 120) + ptr.End() + }) + + widget.Show() + widget.Repaint() + widget.Update() + + qt.QApplication_Exec() +}