How to SetItem() in QTableWidget?

I’m using the Go QT Bindings and have been successful so far by looking at C++ examples when I am unable to figure things out. I am stuck on inserting a data into a given column/row. The entire GUI is about finished with the exception of setting data in the table.

There are several posts regarding this in other languages that show exactly what I am trying to do:
c++ example
python example

When looking at the godocs, there is an argument of type QTableWidgetItem_ITF. I need to convert a string (the data to insert) into a QTableWidgetItem_ITF by means of a QTableWidgetItem_PTR method according to the error/suggestion in VSCode:

cannot use entry (type string) as type widgets.QTableWidgetItem_ITF in argument to t.myTable.SetItem:
    string does not implement widgets.QTableWidgetItem_ITF (missing QTableWidgetItem_PTR method)

The Go code is as shown:

t.myTable.SetItem(index, col, entry)  // entry should be of type widgets.QTableWidgetItem_ITF

I’ve tried several things, including something similar to the above links where I try to use a widget.QTableWidgetItem() or widget.NewQTableWidgetItem() but seem to need to pass a pointer.

How can I insert data into a given table cell?

EDIT: Just as an extra note I am creating the table as shown:

t.myTable = widgets.NewQTableWidget(t.window)
... (more table appearance properties)

and `*widgets.QTableWidget` is in my main struct...

Okay figured it out… it was NewQTableWidgetItem2() that I was searching for:

t.myTable.SetItem(index, col, widgets.NewQTableWidgetItem2(entry, col))

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.