I want to associate additional data with each QTableWidgetItem inserted into the table, in order to use that data in future, when it is being clicked on a table item. But that data should not be visible. How can I do that?
相关问题
- QML: Cannot read property 'xxx' of undefin
- QTextEdit.find() doesn't work in Python
- QT Layouts, how to make widgets in horizontal layo
- QT Layouts, how to make widgets in horizontal layo
- QT GUI freezes even though Im running in separate
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Is there a non-java, cross platform way to launch
- How to get a settings storage path in a cross-plat
- How to set the font size of the label on pushbutto
- Why doesn't valgrind detect a memory leak in m
- QTreeView remove decoration/expand button for all
- qt界面拥挤
You can use
QTableWidgetItem::setData()
like so:Where
myData
is a supported QVariant type. You can useQTableWidgetItem::data()
to retrieve the value that you store.If you need more than one you can use
Qt::UserRole
+ 1, + 2, and so on (Qt::UserRole
is "The first role that can be used for application-specific purposes.", you can read more about the other types of roles here).If you're storing a custom type that isn't natively supported by QVariant you will need to register your type with the Qt meta-object system. Look at QMetaType for more details on that.
If you wanted to store an integer, for example:
You could derive from QTableItem and provide your own data member, or you could use the QTableView with your own model.