handle text flags like axisitem

This commit is contained in:
Ogi Moore 2021-01-31 21:52:51 -08:00
parent d70a009c29
commit e02fc10a40
2 changed files with 9 additions and 14 deletions

View File

@ -418,18 +418,6 @@ if QT_LIB == PYQT6:
for e in QtCore.Qt.Key:
setattr(QtCore.Qt, e.name, e.value)
# TextFlags are not accepted as appropriate types
# Example:
# TypeError: QFontMetric.size(
# self,
# int,
# str,
# tabStops: int = 0,
# tabArray: Optional[List[int]] = 0
# ): argument 1 has unexpected type 'TextFlag'
for e in QtCore.Qt.TextFlag:
setattr(QtCore.Qt, e.name, e.value)
# shim the old names for QPointF mouse coords
QtGui.QSinglePointEvent.localPos = lambda o : o.position()
QtGui.QSinglePointEvent.windowPos = lambda o : o.scenePosition()

View File

@ -1,4 +1,4 @@
from ..Qt import QtGui, QtCore
from ..Qt import QtGui, QtCore, QT_LIB
from ..python2_3 import asUnicode
import os, weakref, re
@ -162,7 +162,14 @@ class ParameterItem(QtGui.QTreeWidgetItem):
# called when the user-visble title has changed (either opts['title'], or name if title is None)
self.setText(0, self.param.title())
fm = QtGui.QFontMetrics(self.font(0))
size = fm.size(QtCore.Qt.TextSingleLine, self.text(0))
if QT_LIB == 'PyQt6':
# PyQt6 doesn't allow or-ing of different enum types
# so we need to take its value property
textFlags = QtCore.Qt.TextSingleLine.value
else:
textFlags = QtCore.Qt.TextSingleLine
size = fm.size(textFlags, self.text(0))
size.setHeight(int(size.height() * 1.35))
size.setWidth(int(size.width() * 1.15))
self.setSizeHint(0, size)