Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Graphic bug



  • hi,
    i just had a strange issue.
    i want to make a CircularGauge - like component using Repeater

    import QtQuick 2.12
    import QtQuick.Controls 2.12
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        id: w
    
    
        property double centerX :150
        property double centerY : 150
        property int rad : 60
    
    
        Slider{
            id: sl
            from: 1
            to : 360
            value: 150
            stepSize: 1
        }
    
    
        Repeater{
                id:rp
                anchors.centerIn: parent
                model:sl.value
    
                Rectangle{
                    height: 10
                    width: 10
                    radius: 5
                    color: "blue"
    
                    x : centerX + (centerX + (rad * Math.sin(index * 2 * (Math.PI / 360))) )
                    y : centerY + (centerY + (rad * Math.cos(index * 2 * (Math.PI / 360))) )
                }
        }
    }
    
    

    01ad58af-2e63-4f01-ab77-a5a8e184817a-image.png

    then if i move the sliders handle ..

    3e4ecb53-b6c0-4ba4-8213-91a2fcbadeea-image.png

    is there something stupid in my code ? Im sure not, because if i remove the the binding of the repeater

    model : sl.value

    and change de model manually it works properly



  • Then custom QQuickPaintedItem? Not sure if having 360 dymically created rectangles is a good idea.



  • Your code is working fine for me with Qt 5.14 and linux mint. Also wouldn't it be better to use Shape and PathArc?



  • hi
    @IntruderExcluder said in Graphic bug:

    Your code is working fine for me with Qt 5.14

    Thank you for confirming. My Qt version is 5.13.0 and platform is windows10.

    I will need to control every point individually, im not sure i can using Shape and PathArc



  • Then custom QQuickPaintedItem? Not sure if having 360 dymically created rectangles is a good idea.



  • @IntruderExcluder said in Graphic bug:

    Not sure if having 360 dymically created rectangles is a good idea.

    That is may be the issue. Because the same code with less rectangles works correctly.
    It looks like the limit is 30... if i bind sliders value to repeaters model

    import QtQuick 2.12
    import QtQuick.Controls 2.12
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        id: w
    
        property double centerX :150
        property double centerY : 150
        property int rad : 60
    
        Slider{
            id: sl
            from: 1
            to :30
            stepSize: 1
        }
    
        Repeater{
                id:rp
                anchors.centerIn: parent
                model:sl.value
    
                Rectangle{
                    height: 10
                    width: 10
                    radius: 5
                    color: "blue"
                    x : centerX + (centerX + (rad * Math.sin(index * 2 * (Math.PI / 30))) )
                    y : centerY + (centerY + (rad * Math.cos(index * 2 * (Math.PI / 30))) )
                }
        }
    }
    

    But if use hardcoded value, i can even put 2000 as model and there is no bug
    This tired me, this is first time i observe such stupid behavior in QtQuick

    @IntruderExcluder thx for your inputs, i will try with QQuickPaintedItem


Log in to reply