Forums

OverviewV-Play 2 Support (Qt 5)Save all entity properties › Reply To: Save all entity properties

OverviewV-Play 2 Support (Qt 5)Save all entity properties › Reply To: Save all entity properties
#9761

Vladimir

Thank you Chris for your solutions !
I tried with “toStoreProperties” but my application crashed :

qml: EntityManager: storeEntitesAsJson: storing entity Entity_QMLTYPE_52(0x2d4b320, "entity_switchEntity_5") of type entity and id entity_switchEntity_5
qml: EntityManager: storing property from toStoreProperties array of entity entry with value SwitchEntry_QMLTYPE_187(0x313db10, "switchEntry_switchEntry_4")
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

I have this structure :
– Entity is a component specialized into SwitchEntity.
– an Entity has an EntityEntry ( specialized into SwitchEntry )

So we have
“Abstract Components”

//Entity.qml
EntityBaseDraggable{
    id: entity
    entityType: "entity"
    toStoreProperties: ["entry"]

    property EntityEntry entry
}

//EntityEntry.qml
Entry{
    id: entityEntry
    entityType: "entityEntry"
    variationType: "entityEntry"

    property bool saved: false
    property bool isTemplate: false
    property bool isModel: false
    property bool hasRessources: false

    property EntryProperties properties
}

 

 

“Concret Components”

//SwitchEntity.qml
Entity{
    id: switchEntity
    entityType: "entity"
    variationType: "switchEntity"
    entry: entry

    Image{
        id: image
        anchors.fill: parent
        source: "../../assets/switch.svg"
    }


    SwitchEntry{
        id: entry
    }
}

//SwitchEntry.qml
EntityEntry{
    id: switchEntry
    entityType: "switchEntry"
    variationType: "switchEntry"
    properties: properties

    property string type
    property int ports
    property bool isHub
    property bool stpEnabled
    property int portMirroring

    SwitchEntryProperties{id: properties}


}

 

I don’t know why it is crashing when I’m saving the level ( It happens when I want to store a component property )
I tried your first solution by putting an ItemEditor in my Scene but the data still are the same.

 

  • This reply was modified 3 years ago by  Reyarc.
  • This reply was modified 3 years ago by  Reyarc.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support