Truthiness of a QHeaderView
Colin Macdonald
cbm at math.ubc.ca
Mon Sep 2 19:14:35 BST 2024
Sometime "recently" (maybe 6.6 or 6.7) I think the truthiness of
QHeaderView has changed, so that `if header:` is no longer True.
Here is the __init__ method of my subclass of QTableWidget:
header = self.horizontalHeader()
print(header)
if header:
print(f"truthiness of {header} confirmed")
else:
print(f"{header} is not truthy!")
if header is not None:
print(f"{header} is not None")
The output is unexpected (to me):
<PyQt6.QtWidgets.QHeaderView object at 0x7fcc20d3ee90>
<PyQt6.QtWidgets.QHeaderView object at 0x7fcc20d3ee90> is not truthy!
<PyQt6.QtWidgets.QHeaderView object at 0x7fcc20d3ee90> is not None
I could probably try to narrow this down a bit, make a MWE etc. But
before I do, does this look familiar? Are my expectations valid? Is it
normal to explicitly check for None rather than to assume truthiness of
PyQt objects?
thanks,
Colin
--
Colin Macdonald
Associate Professor
Dept of Math, UBC
More information about the PyQt
mailing list