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. Assigning an id in the delegate component
Forum Updated to NodeBB v4.3 + New Features

Assigning an id in the delegate component

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 502 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.
  • I Offline
    I Offline
    Idodoqdo
    wrote on last edited by
    #1

    Hello, I want to set the id of the elements that are in delegate, so that later I can access the button signals in Timer. Please tell me how to do this

        Timer {
            interval: 20
            running: zoomminus.pressed || zoomplus.pressed || focusfar.pressed || focusnear.pressed // buttons id
            repeat: true
            onTriggered: {
    
                if (zoomminus.pressed) {
                    nit300.upperFOV()
                } else if (zoomplus.pressed) {
                    nit300.lowerFOV()
                } else if (focusfar.pressed) {
                    nit300.focus++;
                } else if (focusnear.pressed) {
                    nit300.focus--;
                }
            }
        }
    
    
        //    Connections {
        //        target: nit300
    
    
        //    }
    
        GridView {
            id:grid
            anchors.fill: parent
    
            property var actions: {
                "Фокус Far" : function () {print("far")}, //todo;
                "Фокус Near" : function () {print("Near")}, //todo;
                "Автофокус" : function () {nit300.focusAuto()},
                "Зум+" : function () {print("Зум+")}, //todo;
                "Зум-" : function () {print("Зум-")}, //todo;
                "E-Zoom 2X" : function () {nit300.eZoomX2()},
                "Время интегрирования+" : function () {nit300.upperIntegralTime()},
                "Время интегрирования-" : function () {nit300.lowerIntegralTime()},
                "Коррекция" : function () {nit300.correction()},
                "Яркость+" : function () {nit300.upperBrightness()},
                "Яркость-" : function () {nit300.lowerBrightness()},
                "Контраст+" : function () {nit300.upperContrast()},
                "Контраст-" : function () {nit300.lowerContrast()},
                "Positive/Negative" : function () {nit300.polaritySwitch()},
                "DDE--" : function () {nit300.edgeSharpenFast(false)},
                "DDE++" : function () {nit300.edgeSharpenFast(true)},
                "Self Check" : function () {nit300.testImage()},
    
            }
    
            model: [
                {name: "Фокус Far", type: "button"},
                {name: "Фокус Near", type: "button"},
                {name: "Автофокус", type: "button"},
                {name: "f ' = " + nit300.focus/100.0 + " mm", type: "text"},
                {name: "Зум+", type: "button"},
                {name: "Зум-", type: "button"},
                {name: "E-Zoom 2X", type: "button"},
                {name: "FoV",  type: "text"},
                {name: "Время интегрирования+", type: "button"},
                {name: "Время интегрирования-", type: "button"},
                {name: "Коррекция", type: "button"},
                {name: "Зум не норма",  type: "text"},
                {name: "Яркость+", type: "button"},
                {name: "Яркость-", type: "button"},
                {name: "Manual\nBrightContrast", type: "switch"},
                {name: "Фокус не норма", type: "text"},
                {name: "Контраст+", type: "button"},
                {name: "Контраст-", type: "button"},
                {name: "Positive/Negative", type: "button"},
                {name: "Кулер не норма", type: "text"},
                {name: "DDE--", type: "button"},
                {name: "DDE++", type: "button"},
                {name: "Self Check", type: "button"},
                {name: "Температура не норма",  type: "text"},
                {name: "Ошибка связи",  type: "text"},
                {name: "ИК не норма",  type: "text"},
                {name: "Тестовый кадр",  type: "text"},
                {name: "Self Check Fail",  type: "text"},
            ]
    
            cellHeight: height / 7
            cellWidth: width / 4
    
            delegate:
                DelegateChooser {
                role: "type"
                DelegateChoice {
                    roleValue: "button";
                    MyButton2 {
                        width: grid.cellWidth
                        height: grid.cellHeight
                        text: modelData.name
                        onClicked: grid.actions[modelData.name]()
                    }
                }
    
                DelegateChoice {
                    roleValue: "switch"
    
                    MySwitch {
                        width: grid.cellWidth
                        height: grid.cellHeight
                        text: modelData.name
                        font.family: openSans.name
                        onCheckedChanged: {
                            nit300.brightnessContrastAuto(!checked)
                        }
                    }
    
                }
    
                DelegateChoice {
                    roleValue: "text"
                    Rectangle {
                        width: grid.cellWidth
                        height: grid.cellHeight
                        color: root.darkBackgroundColor
                        Text { // todo. Перенос текста на новую строку при изменении размера экрана. Сейчас текст залезает на соседнии элементы
                            anchors.centerIn: parent
                            text: modelData.name
                            color: nit300.tempAlarm ? "orangered" : "mediumspringgreen"
                            font.family: openSans.name
                        }
    
                    }
                }
            }
        }
    
    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Not supposed to this as delegates objects will be dynamically constructed & deleted. You should solve your problem in another way.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      I 1 Reply Last reply
      0
      • dheerendraD dheerendra

        Not supposed to this as delegates objects will be dynamically constructed & deleted. You should solve your problem in another way.

        I Offline
        I Offline
        Idodoqdo
        wrote on last edited by
        #3

        @dheerendra can you please suggest a way to react to the signal of one of the elements in the ListView?

        dheerendraD 1 Reply Last reply
        0
        • I Idodoqdo

          @dheerendra can you please suggest a way to react to the signal of one of the elements in the ListView?

          dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          @Idodoqdo

          function callMe(){
          }

          Inside the delegate add the code. add Identity property of delegate as myId.

          Component.onCompleted :{
          myId.signal.connect(callMe);
          }

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          I 1 Reply Last reply
          0
          • dheerendraD dheerendra

            @Idodoqdo

            function callMe(){
            }

            Inside the delegate add the code. add Identity property of delegate as myId.

            Component.onCompleted :{
            myId.signal.connect(callMe);
            }

            I Offline
            I Offline
            Idodoqdo
            wrote on last edited by
            #5

            @dheerendra Okay, but I need to handle pressing only certain buttons. Please tell me. I'll try on Monday, thanks

            1 Reply Last reply
            0
            • I Idodoqdo 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