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. Combobox
Forum Updated to NodeBB v4.3 + New Features

Combobox

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 954 Views 2 Watching
  • 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.
  • J Offline
    J Offline
    jayashree
    wrote on last edited by
    #1

    Hello

    In combobox, say it contains , model: [ "A", "B", "C", "D" ] . What would be the currentIndex of A, if I give 0 it isn't taking A it points to B.

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by
      #2

      Double check your code. This points to "A" no matter if I use Qt Quick Controls 1 or 2.

      import QtQuick 2.6
      import QtQuick.Controls 2.0 // or 1.0
      
      ApplicationWindow {
          visible: true
      
          ComboBox {
              currentIndex: 0
              model: [ "A", "B", "C", "D" ]
          }
      }
      
      J 1 Reply Last reply
      0
      • jpnurmiJ jpnurmi

        Double check your code. This points to "A" no matter if I use Qt Quick Controls 1 or 2.

        import QtQuick 2.6
        import QtQuick.Controls 2.0 // or 1.0
        
        ApplicationWindow {
            visible: true
        
            ComboBox {
                currentIndex: 0
                model: [ "A", "B", "C", "D" ]
            }
        }
        
        J Offline
        J Offline
        jayashree
        wrote on last edited by
        #3

        @jpnurmi said in Combobox:

        currentIndex: 0

        Thank you for ur reply. My problem is if I select A from the combbox it should open another qml, for that am using currentIndex. If I give obj.currentIndex=0 it should refer A and perform corresponding action, instead it takes B as 0th index and performs B's action.

        1 Reply Last reply
        0
        • jpnurmiJ Offline
          jpnurmiJ Offline
          jpnurmi
          wrote on last edited by
          #4

          Then you might want to provide a simple test case to reproduce the problem. It will help people to help you.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stcorp
            wrote on last edited by
            #5

            You could also possibly use currentText.

            Combining it with the currentTextChanged signal might be useful. Then it would look something like this

            import QtQuick 2.6
            import QtQuick.Controls 2.0 // or 1.0
            
            ApplicationWindow {
                visible: true
            
                ComboBox {
                    currentIndex: 0
                    model: [ "A", "B", "C", "D" ]
                    onCurrentTextChanged: openQML(currentText)
                }
            }
            

            Where openQML(currentText) would be however you are choosing to open your QML file

            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