本文整理汇总了C++中QAbstractSlider::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractSlider::setValue方法的具体用法?C++ QAbstractSlider::setValue怎么用?C++ QAbstractSlider::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractSlider
的用法示例。
在下文中一共展示了QAbstractSlider::setValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitWindow
void SoundSettings::InitWindow()
{
boost::shared_ptr<UiServices::UiModule> ui_module = framework_->GetModuleManager()->GetModule<UiServices::UiModule>(Foundation::Module::MT_UiServices).lock();
// If this occurs, we're most probably operating in headless mode.
if (ui_module.get() == 0)
return;
QUiLoader loader;
QFile file("./data/ui/soundsettings.ui");
if (!file.exists())
{
OpenALAudioModule::LogError("Cannot find sound settings .ui file.");
return;
}
settings_widget_ = loader.load(&file);
if (!settings_widget_)
return;
ui_module->GetInworldSceneController()->AddSettingsWidget(settings_widget_, "Sound");
boost::shared_ptr<Foundation::SoundServiceInterface> soundsystem = framework_->GetServiceManager()->GetService<Foundation::SoundServiceInterface>(Foundation::Service::ST_Sound).lock();
if (!soundsystem.get())
return;
QAbstractSlider* slider = settings_widget_->findChild<QAbstractSlider*>("slider_master");
if (slider)
{
slider->setValue(soundsystem->GetMasterGain() * 100);
QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(MasterGainChanged(int)));
}
slider = settings_widget_->findChild<QAbstractSlider*>("slider_triggered");
if (slider)
{
slider->setValue(soundsystem->GetSoundMasterGain(Foundation::SoundServiceInterface::Triggered) * 100);
QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(TriggeredGainChanged(int)));
}
slider = settings_widget_->findChild<QAbstractSlider*>("slider_ambient");
if (slider)
{
slider->setValue(soundsystem->GetSoundMasterGain(Foundation::SoundServiceInterface::Ambient) * 100);
QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(AmbientGainChanged(int)));
}
slider = settings_widget_->findChild<QAbstractSlider*>("slider_voice");
if (slider)
{
slider->setValue(soundsystem->GetSoundMasterGain(Foundation::SoundServiceInterface::Voice) * 100);
QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(VoiceGainChanged(int)));
}
}
示例2: setValue
bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
{
if ( !editor )
return false;
QgsVectorLayer::EditType editType = vl->editType( idx );
const QgsField &field = vl->pendingFields()[idx];
QVariant::Type myFieldType = field.type();
QSettings settings;
QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
switch ( editType )
{
case QgsVectorLayer::Classification:
case QgsVectorLayer::UniqueValues:
case QgsVectorLayer::Enumeration:
case QgsVectorLayer::ValueMap:
case QgsVectorLayer::ValueRelation:
{
QVariant v = value;
QComboBox *cb = qobject_cast<QComboBox *>( editor );
if ( !cb )
return false;
if ( v.isNull() )
{
v = nullValue;
}
int idx = cb->findData( v );
if ( idx < 0 )
return false;
cb->setCurrentIndex( idx );
}
break;
case QgsVectorLayer::DialRange:
case QgsVectorLayer::SliderRange:
case QgsVectorLayer::EditRange:
{
if ( myFieldType == QVariant::Int )
{
if ( editType == QgsVectorLayer::EditRange )
{
QSpinBox *sb = qobject_cast<QSpinBox *>( editor );
if ( !sb )
return false;
sb->setValue( value.toInt() );
}
else
{
QAbstractSlider *sl = qobject_cast<QAbstractSlider *>( editor );
if ( !sl )
return false;
sl->setValue( value.toInt() );
}
break;
}
else if ( myFieldType == QVariant::Double )
{
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( editor );
if ( !dsb )
return false;
dsb->setValue( value.toDouble() );
}
}
case QgsVectorLayer::CheckBox:
{
QCheckBox *cb = qobject_cast<QCheckBox *>( editor );
if ( cb )
{
QPair<QString, QString> states = vl->checkedState( idx );
cb->setChecked( value == states.first );
break;
}
}
// fall-through
case QgsVectorLayer::LineEdit:
case QgsVectorLayer::UniqueValuesEditable:
case QgsVectorLayer::Immutable:
case QgsVectorLayer::UuidGenerator:
default:
{
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
QTextEdit *te = qobject_cast<QTextEdit *>( editor );
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor );
if ( !le && !te && !pte )
return false;
QString text;
if ( value.isNull() )
{
if ( myFieldType == QVariant::Int || myFieldType == QVariant::Double || myFieldType == QVariant::LongLong )
text = "";
else if ( editType == QgsVectorLayer::UuidGenerator )
//.........这里部分代码省略.........