func ui_main() { w := qt5.NewWidget() defer w.Close() list := qt5.NewListWidget() item := qt5.NewListWidgetItem() item.SetText("Item1") list.AddItem(item) list.AddItem(qt5.NewListWidgetItemWithText("Item2")) button1 := qt5.NewButton() button1.SetText("Нажми меня") button2 := qt5.NewButtonWithText("Изменить стиль фрейма") var sz qt5.Size sz.Height = 35 sz.Width = 300 frame := qt5.NewFrame() frame.SetMinimumSize(sz) button1.SetParent(frame) button2.SetParent(frame) button1.SetPosv(5, 5) button2.SetPosv(100, 5) vbox := qt5.NewVBoxLayout() vbox.AddWidget(frame) vbox.AddWidget(list) w.SetLayout(vbox) style := 1 go func() { button1.OnClicked(func() { fmt.Println("Clicked") button1.SetText("Hello") list.AddItem(qt5.NewListWidgetItemWithText("Привет")) }) button2.OnClicked(func() { fmt.Println(style) frame.SetFrameStyle(style) style++ if style == 7 { style = 0 } }) list.OnCurrentItemChanged(func(item, old *qt5.ListWidgetItem) { //go func() { fmt.Println(item.Attr("text")) //}() }) }() w.Show() qt5.Run() }
func ui_main() { //main window w := qt5.NewWidget() defer w.Close() w.SetGeometryv(10, 10, 500, 500) button2 := qt5.NewButtonWithText("Добавить вкладку") button2.SetSizePolicyHV(0, 0) //create verical layout vbox := qt5.NewVBoxLayout() vbox.AddWidget(button2) //create table table := qt5.NewTableWidget() table.SetRowCount(10) table.SetColumnCount(10) tab := qt5.NewTabWidget() var icon qt5.Icon tab.AddTab(table, "вкладка", &icon) vbox.AddWidget(tab) w.SetLayout(vbox) num := 1 //var ti *qt5.TableWidgetItem go func() { button2.OnClicked(func() { lab := strconv.Itoa(num) tab.AddTab(qt5.NewFrame(), "вкладка "+lab, &icon) num++ }) table.OnCellActivated(func(row int, column int) { fmt.Printf("row=%d column=%d \n", row, column) curit := table.Item(row, column) if curit == nil { ti := qt5.NewTableWidgetItem() ti.SetText("NewItem") table.SetItem(row, column, ti) } else { curit.SetText("ItemExist") } }) }() w.Show() qt5.Run() }