Skip to content

Commit 2822ac8

Browse files
committed
Fix warnings about QFontMetrics.width being deprecated
1 parent 6532d9e commit 2822ac8

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

openmc_plotter/plotgui.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,10 @@ def createGeneralTab(self):
736736
self.maskingCheck = QCheckBox('')
737737
self.maskingCheck.stateChanged.connect(main_window.toggleMasking)
738738

739+
button_width = self.font_metric.boundingRect("XXXXXXXXXX").width()
739740
self.maskColorButton = QPushButton()
740741
self.maskColorButton.setCursor(QtCore.Qt.PointingHandCursor)
741-
self.maskColorButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX"))
742+
self.maskColorButton.setFixedWidth(button_width)
742743
self.maskColorButton.setFixedHeight(self.font_metric.height() * 1.5)
743744
self.maskColorButton.clicked.connect(main_window.editMaskingColor)
744745

@@ -748,7 +749,7 @@ def createGeneralTab(self):
748749

749750
self.hlColorButton = QPushButton()
750751
self.hlColorButton.setCursor(QtCore.Qt.PointingHandCursor)
751-
self.hlColorButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX"))
752+
self.hlColorButton.setFixedWidth(button_width)
752753
self.hlColorButton.setFixedHeight(self.font_metric.height() * 1.5)
753754
self.hlColorButton.clicked.connect(main_window.editHighlightColor)
754755

@@ -764,7 +765,7 @@ def createGeneralTab(self):
764765
# General options
765766
self.bgButton = QPushButton()
766767
self.bgButton.setCursor(QtCore.Qt.PointingHandCursor)
767-
self.bgButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX"))
768+
self.bgButton.setFixedWidth(button_width)
768769
self.bgButton.setFixedHeight(self.font_metric.height() * 1.5)
769770
self.bgButton.clicked.connect(main_window.editBackgroundColor)
770771

@@ -788,7 +789,7 @@ def createGeneralTab(self):
788789

789790
self.overlapColorButton = QPushButton()
790791
self.overlapColorButton.setCursor(QtCore.Qt.PointingHandCursor)
791-
self.overlapColorButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX"))
792+
self.overlapColorButton.setFixedWidth(button_width)
792793
self.overlapColorButton.setFixedHeight(self.font_metric.height() * 1.5)
793794
self.overlapColorButton.clicked.connect(main_window.editOverlapColor)
794795

openmc_plotter/plotmodel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,13 @@ def sizeHint(self, option, index):
984984
column = index.column()
985985

986986
if column == ID:
987-
return QSize(fm.width("XXXXXX"), fm.height())
987+
return QSize(fm.boundingRect("XXXXXX").width(), fm.height())
988988
elif column == COLOR:
989-
return QSize(fm.width("XXXXXX"), fm.height())
989+
return QSize(fm.boundingRect("XXXXXX").width(), fm.height())
990990
elif column == COLORLABEL:
991-
return QSize(fm.width("X(XXX, XXX, XXX)X"), fm.height())
991+
return QSize(fm.boundingRect("X(XXX, XXX, XXX)X").width(), fm.height())
992992
elif column == MASK:
993-
return QSize(fm.width("XXXX"), fm.height())
993+
return QSize(fm.boundingRect("XXXX").width(), fm.height())
994994
else:
995995
return QItemDelegate.sizeHint(self, option, index)
996996

0 commit comments

Comments
 (0)