I want to change the child widget's size when it's parent widget's size changed, but i can't find it's child widget in parent widget. My code such as that:
package main
import (
"fmt"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
"os"
)
type MainWin struct {
*widgets.QWidget
}
func NewMainWin() *MainWin {
win := &MainWin{
widgets.NewQWidget(nil, core.Qt__Widget),
}
win.initUI()
return win
}
func (m *MainWin) initUI() {
m.Resize2(1000, 680)
m.SetWindowTitle("demo")
icon := gui.NewQIcon5("./skin/image/logo.png")
m.SetWindowIcon(icon)
m.ConnectResizeEvent(func(event *gui.QResizeEvent) {
width := m.Width()
height := m.Height()
tab := m.FindChild("TabWidget", core.Qt__FindDirectChildrenOnly)
fmt.Println(tab.IsWidgetType())
tabw := m.Find(tab.PtrI)
fmt.Println(tabw.IsWidgetType())
fmt.Println(tabw)
tabw.Resize2(width, height)
fmt.Println(tabw.Height(), tabw.Width())
})
}
func main() {
app := widgets.NewQApplication(len(os.Args), os.Args)
win := NewMainWin()
tab := widgets.NewQTabWidget(win)
tb1 := widgets.NewQLabel(nil, core.Qt__Widget)
tb1.SetText("Hello")
tab.SetObjectName("TabWidget")
tab.AddTab(tb1, "Hello")
win.Show()
os.Exit(app.Exec())
}
the FindChild("TabWidget", core.Qt__FindDirectChildrenOnly) can find the child, but it is a QObject, it's IsWidgetType() is true, and i can't use it to change it's size, it is not use. so I think i can use the Find(ptr) to get a QWidget, but i found a "&{{{0 widgets.QWidget}} {{0 widgets.QWidget}}}" struct. What should i do?
I use SetObjectName() to define child name, and i try use SetAccessibleName() to set yet. But not used. therecipe/qt QWidget have a function Parent() return the child widget's parent object, and also have a function ParentWidget() return it's parent widget. But for a parent, Can't it find a function to get a child widget?