1 func main() {
2 widgets.NewQApplication(len(os.Args), os.Args)
3
4 table := widgets.NewQTableWidget(nil)
5 table.SetColumnCount(3)
6 table.SetHorizontalHeaderLabels([]string{"编号", "姓名", "年龄"})
7 // 去除边框
8 table.SetShowGrid(false)
9
10 // 设置数据
11 num1 := widgets.NewQTableWidgetItem2("0", 0)
12 name1 := widgets.NewQTableWidgetItem2("anmi", 0)
13 age1 := widgets.NewQTableWidgetItem2("20", 0)
14 table.SetItem(0, 0, num1)
15 table.SetItem(0, 1, name1)
16 table.SetItem(0, 2, age1)
17
18 num2 := widgets.NewQTableWidgetItem2("1", 0)
19 name2 := widgets.NewQTableWidgetItem2("terra", 0)
20 age2 := widgets.NewQTableWidgetItem2("24", 0)
21 table.SetItem(1, 0, num2)
22 table.SetItem(1, 1, name2)
23 table.SetItem(1, 2, age2)
24
25 table.SetWindowTitle("QTableWidget")
26 table.Show()
27
28 widgets.QApplication_Exec()
29 }