Setting QTableView column heading
Rich Shepard
rshepard at appl-ecosys.com
Wed Jun 9 19:47:16 BST 2021
In a module I import:
from PyQt5 import QtWidgets as qtw
from PyQt5 import QtGui as qtg
from PyQt5 import QtCore as qtc
from PyQt5 import QtSql as qts
For the model I have these statements:
self.model = qts.QSqlTableModel()
self.model.setTable(table_name)
self.model.setHeaderData(1, Qt.Horizontal, 'Type')
self.model.select()
When I run the application python tells me:
$ python activitytypes.py
[]
Traceback (most recent call last):
File "activitytypes.py", line 49, in <module>
window = ActTypes()
File "activitytypes.py", line 29, in __init__
self.model.setHeaderData(1, Qt.Horizontal, 'Type')
NameError: name 'Qt' is not defined
I haven't found where Qt.Horizontal is defined. Changing Qt to qtw, qtg,
qtc, and qts all generate the same error.
What am I missing?
Rich
More information about the PyQt
mailing list