Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to reuse objects
Qt 6.11 is out! See what's new in the release blog

How to reuse objects

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 375 Views
  • 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.
  • R Offline
    R Offline
    Roberrt
    wrote on last edited by Roberrt
    #1

    Why is it not creating the particles? i'm not getting any error but the particles aint visible:

    import QtQuick 2.5
    import QtQuick.Particles 2.0
            
    Rectangle {
            id: root
            color: "transparent"
        
            ParticleSystem {
                id: x
            }
            ParticleSystem {
                id: y
            }
         
            Component {
                id: custom
        
                Item {
        
                    ImageParticle {
                        source: 'qrc:/files/particles/assets/particle.png'
                        color: '#ff4208'
                        colorVariation: 0.2
                        rotation: 10
                        rotationVariation: 20
                        rotationVelocity: 20
                        rotationVelocityVariation: 20
                        entryEffect: ImageParticle.Scale
                        opacity: 1
                    }
        
                    Emitter {
                        property string _id: ""
                        anchors.left: parent.left
                        anchors.right: parent.right
                        width: parent.width
                        height: parent.height
        
                        velocity: AngleDirection {
                            angle: 270
                            angleVariation: 180
                            magnitude: 12
                            magnitudeVariation: 20
                        }
                    }
                }
            }
        
            function createEmitter(properties) {
                var obj = custom.createObject(root);
        
                for (var i = 0; i < obj.children.length; i++) {
        
                    var children = obj.children[i];
                    if (children instanceof ImageParticle) {
                        children.system = properties.system;
                        continue;
                    }
                    if (children instanceof Emitter) {
                        children._id               = properties.id;
                        children.system            = properties.system;
                        children.emitRate          = properties.emitRate;
                        children.lifeSpan          = properties.lifeSpan;
                        children.lifeSpanVariation = properties.lifeSpanVariation;
                        children.size              = properties.size;
                        children.maximumEmitted    = properties.maximumEmitted;
                        continue;
                    }
                }
            }
        
            Component.onCompleted: {
        
                createEmitter({ 
                    'id'               : 'emitter1',
                    'system'           : x, 
                    'emitRate'         : 40, 
                    'lifeSpan'         : 4000, 
                    'lifeSpanVariation': 8000, 
                    'size'             : 52, 
                    'maximumEmitted'   : 20 });
        
                createEmitter({ 
                    'id'               : 'emitter2',
                    'system'           : y, 
                    'emitRate'         : 50, 
                    'lifeSpan'         : 5000, 
                    'lifeSpanVariation': 9000, 
                    'size'             : 62, 
                    'maximumEmitted'   : 30 });
            }
    
    1 Reply Last reply
    0

    • Login

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