Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Switch focus on tab press
Qt 6.12 LTS is out! See what's new in the release blog

Switch focus on tab press

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 570 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.
  • G Offline
    G Offline
    Gaurav-Agshift
    wrote on last edited by
    #1

    It's a touch screen program, but the customer wants to use an external keyboard. Please advise on the best method to handle it while pressing the tab key. focus should also change

    jsulmJ 1 Reply Last reply
    0
    • G Gaurav-Agshift

      It's a touch screen program, but the customer wants to use an external keyboard. Please advise on the best method to handle it while pressing the tab key. focus should also change

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Gaurav-Agshift said in Switch focus on tab press:

      Please advise on the best method to handle it while pressing the tab key. focus should also change

      That should work out of the box. What exactly is the problem?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Gaurav-Agshift said in Switch focus on tab press:

        Please advise on the best method to handle it while pressing the tab key. focus should also change

        That should work out of the box. What exactly is the problem?

        G Offline
        G Offline
        Gaurav-Agshift
        wrote on last edited by
        #3

        @jsulmWhen I hit the tab, the focus does not change from one input field to another, and we must instead manually click on the desired field to set it as the focus. However, the user claims they do not want to touch the touchscreen keypad and instead only want to utilise external keypads. when user press enter key or tab so easily focus should change.in below code what to change from gross weight to tare weight after clicking the tab or enter.

        AgShiftNameValue {
        id: dlvyGrossContainer
        objectName: "dlvyGrossContainer"

                            itemHeight: getItemHeight()
        
                            name: qsTr("Dlvy Gross wt")
                            isEnabled: isCheckerboardValid()
                            valueType: "Float"
                            placeValue:   "Tap & Enter"
                            value: root.inspectionGrossWeight
                            valueState: root.inspectionGrossWeight ? "Selected" : "Empty"
                            clickPopup: numericKeypad
                            keypadAlignment: TextInput.AlignTop
        
                            mandatory: (root.inspectionGrossWeight == "") ? true : false
                            visible: !showVarietyWeightPanel() && isWeightVisible()
                            styleSheet: valuesModel._styleSheet
                            sectionConfig: valuesModel.sectionConfig
        
        
        
                            function isWeightVisible() {
                                var m = JSON.parse(Settings.commodities)
                                return root.commodity && root.commodity.length && m[root.commodity.toLowerCase()]["measuredByWeight"]
                                       && !(Session.inspection_type === "training")
                            }
        
                            function initialize() {
                                valueState = root.inspectionGrossWeight ? "Selected" : "Empty"
                            }
        
                            onValueChanged:{
                                  console.debug(logObj.pageAction,Settings.GROSS_WEIGHT_MAX_THRESHOLD   +" dekho kya aaya hai")
        
                                if (Number(root.inspectionGrossWeight) >= Settings.GROSS_WEIGHT_MAX_THRESHOLD || Number(root.inspectionGrossWeight) < Settings.GROSS_WEIGHT_MIN_THRESHOLD) {
                                    notifygrossText.show("Dlvy Gross wt should be greater than or equal to 1 and less than "+ Settings.GROSS_WEIGHT_MAX_THRESHOLD)
                                } else {
                                    notifygrossText.hide()
                                }
                                if(!isEmptyVal(root.inspectionGrossWeight) && root.inspectionTareWeight !== 0){
                                    (Number(root.inspectionTareWeight) >= Number(root.inspectionGrossWeight)) ? notifytareText.show("Dlvy Tare wt should be less than Dlvy Gross weight") : notifytareText.hide()
                                }
                            }
        
                            onSelectionChanged: {
                                root.inspectionGrossWeight = newItem
                            }
                        }
        
        
                        Text {
                            id: notifytareText
                            visible: false
                            width: 300
                            leftPadding: 20
                            anchors.top: dlvyTareContainer.bottom
                            anchors.horizontalCenter: parent.horizontalCenter
                            color: "black"
                            font.pointSize: 12
                            font.family: "Ubuntu"
        
                            function show(message) {
                                text = message
                                visible = true
                            }
        
                            function hide() {
                                visible = false
                                text = ""
                            }
                        }
        
                        AgShiftNameValue {
                            id: dlvyTareContainer
                            objectName: "dlvyTareContainer"
        
                            itemHeight: getItemHeight()
        
                            name: qsTr("Dlvy Tare wt")
                            isEnabled: isCheckerboardValid()
                            valueType: "Float"
                            placeValue: "Tap & Enter"
                            value: root.inspectionTareWeight // ? root.inspectionTareWeight : "0"
                            valueState: root.inspectionTareWeight ? "Selected" : "Empty"
                            clickPopup: numericKeypad
                            keypadAlignment: TextInput.AlignTop
                            mandatory: initialize()
                            visible: !showVarietyWeightPanel() && isWeightVisible()
                            styleSheet: valuesModel._styleSheet
                            sectionConfig: valuesModel.sectionConfig
        
        
        
                            function isWeightVisible() {
                                var m = JSON.parse(Settings.commodities)
                                return root.commodity && root.commodity.length && m[root.commodity.toLowerCase()]["measuredByWeight"]
                                       && !(Session.inspection_type === "training")
                            }
        
                            function initialize() {
                                valueState = root.inspectionTareWeight ? "Selected" : "Empty"
                                return (valueState == "Empty") ? true : false
                            }
        
                            onSelectionChanged: {
                                root.inspectionTareWeight = newItem
                            }
        
                            onValueChanged: {
                                if(!isEmptyVal(root.inspectionGrossWeight)){
                                    (Number(root.inspectionTareWeight) >= Number(root.inspectionGrossWeight)) ? notifytareText.show("Dlvy Tare wt should be less than Dlvy Gross weight") : notifytareText.hide()
                                }
                            }
                        }
        
        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
        • Unsolved