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. Triggering ComboBox Accepted signal using a button outside of ComboBox
Forum Update on Monday, May 27th 2025

Triggering ComboBox Accepted signal using a button outside of ComboBox

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 500 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
    gabor53
    wrote on last edited by
    #1

    Hi,
    I have a ComboBox on a form. I also have a button on the form which the user need to press to process the data on the form.

    ComboBox {
    width: 200
    model: [ "Banana", "Apple", "Coconut" ]
    }

    Right now I have to click on the ComboBox to accept the content and trigger the Accepted() signal.
    Is it possible to accept the ComboBox content and trigger the Accepted() signal using a StyledButton which is independent from the ComboBox?
    The goal is to read all the textfield and ComboBox content by clicking only once at the StyledButton.
    Thank you.

    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #2

      Signals are very similar to functions, you may simply call this signal manually like yourComboBoxId.accepted() at onClicked button's slot.

      G 1 Reply Last reply
      2
      • IntruderExcluderI IntruderExcluder

        Signals are very similar to functions, you may simply call this signal manually like yourComboBoxId.accepted() at onClicked button's slot.

        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #3

        Hi @intruderexcluder ,
        I tried

        WhatCombo.accepted()
        

        accepted() was not offered as an option after hitting .
        It did not give any specific error messages just doesn't work.
        Thank you.

        1 Reply Last reply
        0
        • IntruderExcluderI Offline
          IntruderExcluderI Offline
          IntruderExcluder
          wrote on last edited by IntruderExcluder
          #4

          I was talking about like this:

          ...
          MyCustomComboBox {
              id: mycombo
              ...
          }
          ...
          MyCustomButton {
              ...
              onClicked: {
                  ...
                  mycombo.accepted();
              }
          }
          
          G 1 Reply Last reply
          2
          • IntruderExcluderI IntruderExcluder

            I was talking about like this:

            ...
            MyCustomComboBox {
                id: mycombo
                ...
            }
            ...
            MyCustomButton {
                ...
                onClicked: {
                    ...
                    mycombo.accepted();
                }
            }
            
            G Offline
            G Offline
            gabor53
            wrote on last edited by
            #5

            @intruderexcluder
            I have the following:

                WhatCombo {
                    id: whatCombo
                    anchors.left: comboInstruct.left
                    anchors.top: comboInstruct.bottom
                    anchors.topMargin: 10
                }
            
                    onClicked: {
                       console.log("submit clicked.")
                      whatCombo.accepted()
            }
            
            

            I think it should work, but it doesn't.

            1 Reply Last reply
            -1
            • IntruderExcluderI Offline
              IntruderExcluderI Offline
              IntruderExcluder
              wrote on last edited by
              #6

              Just wrote a minumum example and it works fine:

              Window {
                  id: root
                  visible: true
                  width: 640
                  height: 480
                  title: qsTr("Hello World")
              
                  ComboBox {
                      id: cb
                      model: ["asd", "qwe", "zxc"]
                  }
              
                  Button {
                      anchors.centerIn: parent
                      text: "Test"
                      onClicked: cb.accepted()
                  }
              
                  Connections {
                      target: cb
                      onAccepted: console.log("COMBO ACCEPTED");
                  }
              }
              
              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved