I have think and searched on the doc of Qt and found some function who could make the code auto.
Here the actual code using these function based on the base QDoubleSpinBox code, so should be correct ?
QSize CDoubleSliderSpinBox::sizeHint() const
{
// Be sure for valid calcule.
ensurePolished();

// Compute text size.
const QFontMetrics FontMetrics = fontMetrics();
const int TextWidth = FontMetrics.width( text() );
const int TextHeight = lineEdit()->sizeHint().height();

// Initialize the SpinBox style option.
QStyleOptionSpinBox opt;
initStyleOption( &opt );

// Set the style option rect.
opt.rect = rect();

// Compute the size from contents.
const QSize ContentSize = QSize( TextWidth, TextHeight );
const QSize SizeFromContents = style()->sizeFromContents( QStyle::CT_SpinBox, &opt, ContentSize, this );

// Return the final size.
return SizeFromContents.expandedTo( QApplication::globalStrut() );
}
It's funky to have size hint working correctly.