Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

xxxToVariant()

Help
2011-01-13
2013-05-22
  • Gary Harris
    Gary Harris
    2011-01-13

    I'm wondering how to do the equivalent of wxColourPropertyValueFromVariant() and wxColourPropertyValueToVariant() in the version implemented in WX2.9. That implementation lacks these functions in the generic classes. I've tried all sorts of things across several days of trying, casting, importing old code from advprops.h, etc with no luck. Is there a way to do this?

    Thanks.

     
  • Jaakko Salli
    Jaakko Salli
    2011-01-13

    wxPropertyGrid now uses the same system as the other wxVariant types not natively implemented in variant.cpp. For example:

    wxColourPropertyValue col;
    wxVariant variant = prop->GetValue();
    col << variant;
    ...
    variant << col;
    prop->SetValue(variant);
    

    There should be more info in the wxVariant documentation. You can also use the new template-based wxAny class, which should be handier in most cases (note: GetValue() only returns wxVariant, but it is implicitly converted to wxAny in the example):

        wxAny value = prop->GetValue();
        wxColourPropertyValue col = value.As<wxColourPropertyValue>();
    
     
  • Jaakko Salli
    Jaakko Salli
    2011-01-13

    Sorry, I may have spoken too soon about wxVariant<->wxAny conversion support. I actually think it only works for built-in types and some native wxWidgets compound types.