QSpinBox应用

1、当QSpinBox的值为最小值时, 显示特殊的字符

 

     QSpinBox *zoomSpinBox = new QSpinBox;
     zoomSpinBox->setRange(0, 1000);
     zoomSpinBox->setSingleStep(10);
     zoomSpinBox->setSpecialValueText(tr("Automatic"));
     zoomSpinBox->setValue(100);

 

2、显示前缀/后缀

 

      zoomSpinBox->setSuffix("%");
     zoomSpinBox->setPrefix("$"));
 

 

3、

QString QSpinBox::textFromValue ( int value ) const [virtual protected]

This virtual function is used by the spin box whenever it needs to display the given value. The default implementation returns a string containing valueprinted in the standard way using QWidget::locale().toString(), but with the thousand separator removed. Reimplementations may return anything. (See the example in the detailed description.)

Note: QSpinBox does not call this function for specialValueText() and that neither prefix() nor suffix() should be included in the return value.

If you reimplement this, you may also need to reimplement valueFromText() and validate()

 

   

你可能感兴趣的:(function,String)