mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 00:48:38 +00:00
bindings: add CPointer() helper to support nil widget parents
This commit is contained in:
parent
986b87c3a4
commit
a9c74647ec
11
binding.go
11
binding.go
@ -47,6 +47,13 @@ type QWidget struct {
|
||||
h C.PQWidget
|
||||
}
|
||||
|
||||
func (this *QWidget) CPointer() C.PQWidget {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return this.h
|
||||
}
|
||||
|
||||
func NewQWidget() *QWidget {
|
||||
ret := C.QWidget_new()
|
||||
return &QWidget{h: ret}
|
||||
@ -62,8 +69,8 @@ type QPushButton struct {
|
||||
h C.PQPushButton
|
||||
}
|
||||
|
||||
func NewQPushButton(label string, parent QWidget) *QPushButton {
|
||||
h := C.QPushButton_new(C.CString(label), parent.h)
|
||||
func NewQPushButton(label string, parent *QWidget) *QPushButton {
|
||||
h := C.QPushButton_new(C.CString(label), parent.CPointer())
|
||||
return &QPushButton{h: h}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user