Skip to content

Commit

Permalink
Qt6: Fix usage of deprecated QApplication::fontMetrics()
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Oct 4, 2024
1 parent bf1c7f4 commit 3797aa8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ QSize QShortenedLabel::minimumSizeHint() const
{
const int minimumNumberOfCharacters = 10;

QFontMetrics fontMetrics = QApplication::fontMetrics();
QFontMetrics fontMetrics( QApplication::font() );
QString fullLabelText = fullText();
QString shortenedText = fullLabelText.left( minimumNumberOfCharacters );
int minimumWidth = fontMetrics.horizontalAdvance( shortenedText );
Expand Down Expand Up @@ -118,8 +118,8 @@ QSize QShortenedLabel::minimumSizeHint() const
//--------------------------------------------------------------------------------------------------
QSize QShortenedLabel::sizeHint() const
{
QFontMetrics fontMetrics = QApplication::fontMetrics();
QString labelText = fullText();
QFontMetrics fontMetrics( QApplication::font() );
QString labelText = fullText();

QStringList labelLines = labelText.split( "\n" );
int maxLineWidth = 0;
Expand Down Expand Up @@ -147,8 +147,8 @@ void QShortenedLabel::resizeEvent( QResizeEvent* event )
//--------------------------------------------------------------------------------------------------
void caf::QShortenedLabel::resizeText( QSize paintSize )
{
QString labelText = fullText();
QFontMetrics fontMetrics = QApplication::fontMetrics();
QString labelText = fullText();
QFontMetrics fontMetrics( QApplication::font() );

QStringList labelLines = labelText.split( "\n" );
int maxLineWidth = 0;
Expand Down
2 changes: 1 addition & 1 deletion Fwk/AppFwk/cafUserInterface/cafPdmUiColorEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ QWidget* PdmUiColorEditor::createEditorWidget( QWidget* parent )
m_colorPreviewLabel->setText( QLatin1String( "..." ) );
m_colorPreviewLabel->setAlignment( Qt::AlignCenter );

QFontMetrics fontMetrics = QApplication::fontMetrics();
QFontMetrics fontMetrics( QApplication::font() );

buttonLayout->addWidget( m_colorPreviewLabel );
m_colorSelectionButton->setMinimumWidth( fontMetrics.boundingRect( m_colorPreviewLabel->text() ).width() + 15 );
Expand Down

0 comments on commit 3797aa8

Please sign in to comment.