C++ (Qt)QSettings s( "options.ini", QSettings::IniFormat );foreach( QWidget* tw, dialog->findChildren< QTabWidget* >() ){ foreach( QWidget* w, tw->findChildren< QWidget* >() ) { if( qobject_cast< QLabel* >( w ) ) continue; QString key = dialog->objectName() + '/' + tw->objectName() + '/' + w->objectName(); if( QLineEdit* le = qobject_cast< QLineEdit* >( w ) ) { if( is_saving ) { s.setValue( key, le->text() ); } else { QVariant v = s.value( key ); if( v.isValid() ) le->setText( v.toString() ); else qWarning( w->objectName() + ": invalid value" ); } } else if( QSpinBox* sb = qobject_cast< QSpinBox* >( w ) ) { if( is_saving ) { s.setValue( key, sb->value() ); } else { QVariant v = s.value( key ); if( v.isValid() ) sb->setValue( v.toInt() ); else qWarning( w->objectName() + ": invalid value" ); } } else if( ... ) { } }}
// QList<QPair<QVariant, QVariant>> valueList_;QSettings setting(sbSettingsFileName_, QSettings::IniFormat);setting.setIniCodec("Windows-1251");for(int i = 0; i < valueList_.size();i++){setting.setValue( valueList_[i].first(), valueList_[i].second());}
C++ (Qt)QSettings s( "options.ini", QSettings::IniFormat );foreach( QWidget* tw, dialog->findChildren< QTabWidget* >() )...
C++ (Qt)for (int i = 0; i < converters.size(); ++i) if (converter[i]->Data2UI(widget, settings, prefix, &errCode)) break;
C++ (Qt)static ParamBlockDesc2 strata_param_blk ( strata_params, _T("params"), 0, &StrataDesc, P_AUTO_CONSTRUCT + P_AUTO_UI, PBLOCK_REF, //rollout IDD_PANEL, IDS_PARAMS, 0, 0, NULL,// params pb_objsize, _T("Object Size"), TYPE_FLOAT, P_ANIMATABLE, IDS_SPIN_SIZE, p_default, 1.0f, p_range, 0.0f, 1000000.0f, p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_EDIT_SIZE, IDC_SPIN_SIZE, 1.0f, end, pb_height, _T("Height"), TYPE_FLOAT, P_ANIMATABLE, IDS_SPIN_HEIGHT, p_default, 1.0f, p_range, -1000000.0f, 1000000.0f, p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_EDIT_HEIGHT, IDC_SPIN_HEIGHT, 1.0f, end, pb_combo_scheme, _T("Use Preset"), TYPE_INT, 0, IDS_FW_PRESET, p_default, 0, p_ui, TYPE_INTLISTBOX, IDC_COMBO_PRESET, 0, p_accessor, &comboPBAccessor, end, pb_combo_browse, _T("Browse Style"), TYPE_INT, 0, IDS_FW_PRESET, p_default, 0, p_ui, TYPE_INTLISTBOX, IDC_COMBO_BROWSE, 3, IDS_BRW_NRML, IDS_BRW_SAVCOL, IDS_BRW_COLONLY, p_accessor, &comboPBAccessor, end, pb_combo_grad, _T("Gradient"), TYPE_INT, 0, IDS_FW_GRADIENT, p_default, 0, p_ui, TYPE_INTLISTBOX, IDC_COMBO_COLOR, 4, IDS_GRAD1, IDS_GRAD2, IDS_GRAD3, IDS_GRAD4, p_accessor, &comboPBAccessor, end, // gradient count, colors & keys pb_numkey, _T("NumKey"), TYPE_INT, 0, IDS_FW_GRADIENT, end, pb_selkey, _T("SelKey"), TYPE_BOOL, 0, IDS_FW_GRADIENT, end, pb_color0, _T("Color0"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR1, end, pb_color1, _T("Color1"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR2, end, pb_color2, _T("Color2"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR3, end, pb_color3, _T("Color3"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR4, end, pb_color4, _T("Color4"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR5, end, pb_color5, _T("Color5"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR6, end, pb_color6, _T("Color6"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR7, end, pb_color7, _T("Color7"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR8, end, pb_color8, _T("Color8"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR9, end, pb_color9, _T("Color9"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR10, end, pb_color10, _T("Color10"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR11, end, pb_color11, _T("Color11"), TYPE_RGBA, P_ANIMATABLE, IDS_COLOR12, end, pb_X0, _T("KeyX0"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS1, p_range, 0.0f, 1.0f, end, pb_X1, _T("KeyX1"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS2, p_range, 0.0f, 1.0f, end, pb_X2, _T("KeyX2"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS3, p_range, 0.0f, 1.0f, end, pb_X3, _T("KeyX3"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS4, p_range, 0.0f, 1.0f, end, pb_X4, _T("KeyX4"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS5, p_range, 0.0f, 1.0f, end, pb_X5, _T("KeyX5"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS6, p_range, 0.0f, 1.0f, end, pb_X6, _T("KeyX6"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS7, p_range, 0.0f, 1.0f, end, pb_X7, _T("KeyX7"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS8, p_range, 0.0f, 1.0f, end, pb_X8, _T("KeyX8"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS9, p_range, 0.0f, 1.0f, end, pb_X9, _T("KeyX9"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS10, p_range, 0.0f, 1.0f, end, pb_X10, _T("KeyX10"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS11, p_range, 0.0f, 1.0f, end, pb_X11, _T("KeyX11"), TYPE_FLOAT, P_ANIMATABLE, IDS_OFS12, p_range, 0.0f, 1.0f, end, // coordinates pb_coords, _T("coords"), TYPE_REFTARG, P_OWNERS_REF, IDS_COORDS, p_refno, COORD_REF, end, pb_graymode, _T("GrayMODE"), TYPE_BOOL, 0, IDS_GRAYMODE, p_default, FALSE, p_ui, TYPE_SINGLECHEKBOX, IDC_CHECKGRAY, end, end );