Bug 355779

Summary: Add the property childrenRect to QMLItem
Product: [Unmaintained] QmlWeb Reporter: Igor A. <igor.andruszkiewicz>
Component: QtQuickAssignee: Anton Kreuzkamp <akreuzkamp>
Status: RESOLVED UNMAINTAINED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Igor A. 2015-11-23 13:11:33 UTC
According to QML documentation Item must contain childrenRect object with properties (x,y,width,height). It's very useful and used frequently with ListView and Repeater. 

http://doc.qt.io/qt-5/qml-qtquick-item.html#childrenRect-prop

Reproducible: Always


Actual Results:  
No property  childrenRecct
Comment 1 Igor A. 2015-11-28 22:53:52 UTC
It works fine but I don't know how to update internally read only property yet. 

Here are my changes:

1) function computing the Rect 
function updateChildrenRect(component){
    
    var children = component !== undefined ? component.children : undefined
    if ( children == undefined || children.length == 0 )
        return;
    
    var maxWidth = 0;
    var maxHeight = 0;
    var minX = children.length>0 ? children[0].x : 0;
    var minY = children.length>0 ? children[0].y : 0;
    var h=0;
    var w=0;
    
    for(var i in children){
        var child = children[i];
        
        h = child.$isUsingImplicitHeight !== 0 ? child.implicitHeight : child.height;
        w = child.$isUsingImplicitWidth !== 0 ? child.implicitWidth : child.width;
        
        maxWidth = Math.max(maxWidth, child.x + w); 
        maxHeight = Math.max(maxHeight, child.y + h);
        minX = Math.min(minX, child.x);
        minY = Math.min(minX, child.y);
    }
    
    component.childrenRect.x = minX;
    component.childrenRect.y = minY;
    component.childrenRect.width = maxWidth;
    component.childrenRect.height = maxHeight; 
}

2) above to be called from  updateVGeometry and updateHGeometry

if (this.parent != undefined) updateChildrenRect(this.parent);

3) and a childrenRect property for QMLItem

    this.childrenRect = new QObject(this);
    createSimpleProperty("real", this.childrenRect, "x","rw");  //todo ro 
    createSimpleProperty("real", this.childrenRect, "y","rw");  // todo ro
    createSimpleProperty("real", this.childrenRect, "width","rw"); // todo ro
    createSimpleProperty("real", this.childrenRect, "height","rw"); // todo ro
Comment 2 Justin Zobel 2021-03-09 07:30:36 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 3 Christoph Cullmann 2025-06-10 16:57:34 UTC
This project is unfortunately no longer maintained.

If a new maintainer wants to step up and take care, the project is archived here:

https://invent.kde.org/unmaintained/qmlweb

You can just clone it in your private namespace on invent.kde.org and if you have started to work on it and fixed/implemented something get it reviewed and the project unarchived.

Sorry for the inconveniences.