0

At the moment I am working with face recognition and have to create a module for the GUI, every time a face is recognised I need to display the new item with different strings and images also needs to display it n number of times, what is the best way to go about this? This is the item:

Item{
    width: 300
    height: 300
    property string names;

Rectangle{
    property int yvalue;
    id: firstrect
    x: 29
    y: yvalue
    width: 300
    height: 300
    color: "white"
    border.color: "#d3d3d3"
    border.width: 5
    visible: true
    //property values to pass to grid elements when needed
    property string name : names;
    property string matchpercentage;
    property string conflevel;
    property string firstrectcolor;
    property string secondrectcolor;
    property int progressValue;
    property bool startAnim;
    Timer{
        running: true
        repeat: true
        interval: 6000
        onTriggered: {
            coloranim1.to = "white"
            coloranim1.running = true

        }
    }

    ColorAnimation on color {
        id: coloranim
        to: "light blue"
        duration: 1000
        running: if(firstrect.visible === true)
                 {
                     true
                 }
                 else
                     false
        loops: 1
    }
    ColorAnimation on color {
        id: coloranim1
        to: "white"
        duration: 1000
        running: if(firstrect.visible === true)
                 {
                     true
                 }
                 else
                     false
        loops: 1
    }
//                    SequentialAnimation{
//                        running: if(firstrect.visible === true)
//                                 {
//                                     true
//                                 }
//                                 else
//                                     false

//                        ColorAnimation {
//                            to: "light blue"
//                            from:
//                            duration: 2000
//                        }

//                        ColorAnimation {
//                            to: "white"
//                            duration: 1000
//                        }
//                    }

    MouseArea{
        anchors.fill: parent
    }
    Image{
        id: infoicon
        x: 263
        y: 264
        width: 31
        height: 30
//        source: infomarea.containsMouse ?  "infoiconhover.png" : "infoicon.png"
        MouseArea{
            id: infomarea
            anchors.fill: parent
            hoverEnabled: true
            onClicked: {
                userinf.visible = true
                userinf.textinputnameuserinfo.text = firstrect.name
            }
        }
    }

    Rectangle{
        id: firstimage
        x: 10
        y: 14
        width: 139
        height: 129
        color: "light grey"
        border.color: if(parent.firstrectcolor === "")
                      {
                          "#b72c2f"
                      }
                      else
                      parent.firstrectcolor
        border.width: 3
        Image {
            width: 135
            height: 125
            anchors.centerIn: parent
//            source: "1_Josh.png"
        }
    }
    Rectangle{
        id: secimage
        x: 153
        y: 14
        width: 139
        height: 129
        color: "light grey"
        border.color: "#b72c2f"
        border.width: 3
        Image {
            width: 135
            height: 125
            anchors.centerIn: parent
//            source: "5_Josh.png"
        }
    }

    TextInput {
        id: textInputname
        x: 10
        y: 181
        width: 180
        height: 18
        text: parent.name
        font.family: "Arial"
        horizontalAlignment: Text.AlignLeft
        font.pixelSize: 14
        z: 1
        readOnly: true
    }

    TextInput {
        id: textInputmatchpercentage
        x: 120
        y: 210
        width: 63
        height: 20
        text: parent.matchpercentage
        font.family: "Arial"
        horizontalAlignment: Text.AlignHCenter
        font.pixelSize: 20
        z: 1
        readOnly: true
    }

    Text {
        id: text1
        x: 10
        y: 211
        width: 111
        height: 14
        text: qsTr("Match Percentage:")
        font.family: "Arial"
        font.pixelSize: 14

    }
//    SimpleProgressBar{
//        id: progress
//        x: 92
//        y: 254
//        width: 100
//        height: 16
//        color: if(progress.value >= 50)
//               {
//                   "light green"
//               }
//               else if(progress.value < 50){
//                    "red"
//               }
//        value: parent.progressValue
//    }
}
}
3
  • Use a (List)-Model within a ListView. Each new "face" element can be appended at the model.
    – sk2212
    Nov 19, 2015 at 13:25
  • But how do I add the rectangle repeatedly with different values to a list model? I have attempted to do that before and was only able to do when I statically instantiated the rectangles in the model before runtime. Nov 19, 2015 at 13:38
  • Please read doc.qt.io/qt-5/qml-qtquick-listview.html
    – sk2212
    Nov 19, 2015 at 14:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.