Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Q: Qt - [c++] replacing material on a QEntity
Forum Updated to NodeBB v4.3 + New Features

Q: Qt - [c++] replacing material on a QEntity

Scheduled Pinned Locked Moved Solved Game Development
3 Posts 2 Posters 696 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kevin_d
    wrote on last edited by
    #1

    Hello Forum!

    How can i remove a QMaterial* component from a QEntity the safe way?
    given the sequence:

    // create the objects (of course with suitable arguments)
    auto* entity = new Qt3DCore::QEntity(_root);
    auto* mesh = new Qt3DExtras::QCuboidMesh;
    auto* scaleTransform = new Qt3DCore::QTransform;
    auto* material = new Qt3DExtras::QPhongMaterial;
    auto* anotherScaleTransform = new Qt3DCore::QTransform;
    
    // assign unordered
    entity->addComponent(mesh),
    entity->addComponent(scaleTransform);
    entity->addComponent(material);
    entity->addComponent(anotherScaleTransform);
    
    // what i want:
    entity->removeComponent(material);
    entity->addComponent(anotherMaterial);
    

    best regards, kevin

    kshegunovK 1 Reply Last reply
    0
    • K kevin_d

      Hello Forum!

      How can i remove a QMaterial* component from a QEntity the safe way?
      given the sequence:

      // create the objects (of course with suitable arguments)
      auto* entity = new Qt3DCore::QEntity(_root);
      auto* mesh = new Qt3DExtras::QCuboidMesh;
      auto* scaleTransform = new Qt3DCore::QTransform;
      auto* material = new Qt3DExtras::QPhongMaterial;
      auto* anotherScaleTransform = new Qt3DCore::QTransform;
      
      // assign unordered
      entity->addComponent(mesh),
      entity->addComponent(scaleTransform);
      entity->addComponent(material);
      entity->addComponent(anotherScaleTransform);
      
      // what i want:
      entity->removeComponent(material);
      entity->addComponent(anotherMaterial);
      

      best regards, kevin

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @kevin_d said in Q: Qt - [c++] replacing material on a QEntity:

      How can i remove a QMaterial* component from a QEntity the safe way?

      This is the correct way.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kevin_d
        wrote on last edited by
        #3

        good. thanks!

        1 Reply Last reply
        0
        • K kevin_d has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved