Changing UProperty editability in Runtime

Is it possible to change a UProperty editabilty at editor runtime?
I want to achieve something like this:

80684-vdec.png

80683-vact.png

void ATest::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
    if (UProperty* Property = PropertyChangedEvent.Property)
    {   
        if (Property->GetFName() == GET_MEMBER_NAME_CHECKED(ATest, test))
        {
            for (TFieldIterator<UProperty> PropIt(GetClass()); PropIt; ++PropIt)
            {
                if (PropIt->GetFName() == GET_MEMBER_NAME_CHECKED(ATest, var1))
                {
                    if (test)
                        // Set var1 editable
                    else
                        // Set var1 readonly
                }
                else if (PropIt->GetFName() == GET_MEMBER_NAME_CHECKED(ATest, var2))
                {
                    if (test)
                        // Set var2 readonly
                    else
                        // Set var2 editable
                }
            }
        }
    }
}

I tried to change the property flags via SetPropertyFlags() like this:

uint64 flags = Property->GetPropertyFlags();
flags |= CPF_BlueprintReadOnly;
flags &= !CPF_Edit;
Property->SetPropertyFlags(flags);

I even tried to swap the flags between var1 and var2, but it doesn’t work. Am I missing something?
I think the editor might need a refresh call or something like that.

Note: The example exposed is a very simplified version of what I’m currently working at.

Did you try looking into existing code? Directional light comes to mind with enabling/disabling cascade shadows options depending on set mobility.

U can write ur custom Details Property interface for ur class, as here (at ~9:00 ) : UE4 ABulletPenetrationPlugin : InAction - YouTube
. But have not reason if u want customize only 1 property.
ps: sorry for English

EditCondition uproperty seems to be exactly what you are loooking for.