mirror of
https://github.com/mappu/miqt.git
synced 2025-04-02 20:00:23 +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
|
h C.PQWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *QWidget) CPointer() C.PQWidget {
|
||||||
|
if this == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return this.h
|
||||||
|
}
|
||||||
|
|
||||||
func NewQWidget() *QWidget {
|
func NewQWidget() *QWidget {
|
||||||
ret := C.QWidget_new()
|
ret := C.QWidget_new()
|
||||||
return &QWidget{h: ret}
|
return &QWidget{h: ret}
|
||||||
@ -62,8 +69,8 @@ type QPushButton struct {
|
|||||||
h C.PQPushButton
|
h C.PQPushButton
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewQPushButton(label string, parent QWidget) *QPushButton {
|
func NewQPushButton(label string, parent *QWidget) *QPushButton {
|
||||||
h := C.QPushButton_new(C.CString(label), parent.h)
|
h := C.QPushButton_new(C.CString(label), parent.CPointer())
|
||||||
return &QPushButton{h: h}
|
return &QPushButton{h: h}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user