Qt6: Fix usage of deprecated QApplication::fontMetrics()

This commit is contained in:
Kristian Bendiksen 2024-10-02 12:34:24 +02:00
parent bf1c7f4b04
commit 3797aa8211
2 changed files with 6 additions and 6 deletions

View File

@ -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 );
@ -118,7 +118,7 @@ QSize QShortenedLabel::minimumSizeHint() const
//--------------------------------------------------------------------------------------------------
QSize QShortenedLabel::sizeHint() const
{
QFontMetrics fontMetrics = QApplication::fontMetrics();
QFontMetrics fontMetrics( QApplication::font() );
QString labelText = fullText();
QStringList labelLines = labelText.split( "\n" );
@ -148,7 +148,7 @@ void QShortenedLabel::resizeEvent( QResizeEvent* event )
void caf::QShortenedLabel::resizeText( QSize paintSize )
{
QString labelText = fullText();
QFontMetrics fontMetrics = QApplication::fontMetrics();
QFontMetrics fontMetrics( QApplication::font() );
QStringList labelLines = labelText.split( "\n" );
int maxLineWidth = 0;

View File

@ -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 );