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. Combo boxes have different values after selecting a value and when displaying choices
Forum Updated to NodeBB v4.3 + New Features

Combo boxes have different values after selecting a value and when displaying choices

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 560 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.
  • R Offline
    R Offline
    Ren.K
    wrote on last edited by
    #1

    Hi all, I'm using the QMl combo box.
    Different values after value selection and when displaying choices.

    Why are they different?
    How can we get the same value?

    combobox.PNG

        ListModel {
            id: listModel
            ListElement {
                name: "A & B"
            }
            ListElement {
                name: "&&&"
            }
        }
    
        ComboBox {
            id: comboBox
            textRole: "name"
            model: listModel
        }
    
    JonBJ 1 Reply Last reply
    0
    • R Ren.K

      Hi all, I'm using the QMl combo box.
      Different values after value selection and when displaying choices.

      Why are they different?
      How can we get the same value?

      combobox.PNG

          ListModel {
              id: listModel
              ListElement {
                  name: "A & B"
              }
              ListElement {
                  name: "&&&"
              }
          }
      
          ComboBox {
              id: comboBox
              textRole: "name"
              model: listModel
          }
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Ren-K
      They are different because & is used before a character to indicate it is a shortcut. That is why you get the underline character in A & B -> A _B.

      I don't know QML, but in the first case you are in something which does not do shortcuts so it shows A & B literally. In the second case it does accept shortcut key input and so displays with that information.

      Simplest would be if you can avoid & characters in the texts altogether. Otherwise you will apparently have to do something to translate & to && for the second case, which will be displayed as literal single &. How you do this from QML (do you need to go via script?) I do not know.

      R 1 Reply Last reply
      0
      • JonBJ JonB

        @Ren-K
        They are different because & is used before a character to indicate it is a shortcut. That is why you get the underline character in A & B -> A _B.

        I don't know QML, but in the first case you are in something which does not do shortcuts so it shows A & B literally. In the second case it does accept shortcut key input and so displays with that information.

        Simplest would be if you can avoid & characters in the texts altogether. Otherwise you will apparently have to do something to translate & to && for the second case, which will be displayed as literal single &. How you do this from QML (do you need to go via script?) I do not know.

        R Offline
        R Offline
        Ren.K
        wrote on last edited by
        #3

        @JonB
        Thanks to you, I understood that & is a shortcut character.

        Hey guys, I want to display the same value in both cases.
        Please help me.

        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 Extensions
        • Unsolved