Как-то так:
C++ (Qt)
class ScaleComboBox : public QComboBox
{
Q_OBJECT
public:
ScaleComboBox( QWidget* parent = 0 ) : QComboBox( parent ) {}
virtual ~ScaleComboBox() {}
protected:
void showPopup()
{
QComboBox::showPopup();
QLocale locale( C );
float cs = locale.toFloat( currentText().replace( ':', '.' ) );
float min = 999999;
int min_index = 0;
for( int i = 0; i < count(); i++ )
{
float s = locale.toFloat( itemText( i ).replace( ':', '.' ) );
if( qAbs( cs - s ) < min )
{
min = qAbs( cs - s );
min_index = i;
}
}
blockSignals( true );
view()->setCurrentIndex( model()->index( min_index, 0 ) );
blockSignals( false );
}
};