Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Help] QComboBox multiple events

[Help] QComboBox multiple events

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.2k 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.
  • N Offline
    N Offline
    Neko
    wrote on last edited by
    #1

    Hello,
    i have a pretty simple question and i didnt found a solution on google yet.

    Is it possible to have 2 different events connected to a click on the QComboBox ?
    What i need is the following:

    Event A: Click on the Box -> Do Function A
    Event B: Click on the Arrow -> Toggle Dropdown

    Kind regards

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The dropdown is shown when you click on the arrow. What do you want to happen when you click in the line edit of the QComboBox ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Neko
        wrote on last edited by
        #3

        The dropdown is shown when i click anywhere on the combobox. Not just the arrow.

        Let me explain it again:

        [My1stEntry | ▼]
        [My2ndEntry]
        [My3rdEntry]

        • Click on Arrow: Toggle Dropdown
        • Click on Entry (Dropdown off): Call function defined by me.
        • Click on Entry (Dropdown on:) Set selected entry as current selected.

        Maybe this helps more in terms of understanding.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          As written before the handling of the dropdown is already there.

          The only thing you have to do is connect the QComboBox::activated signal to the function you want to call when an item is selected.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • N Offline
            N Offline
            Neko
            wrote on last edited by
            #5

            Okay, then i simply don't get it. Because right now it doesn't matter where i click on the combobox, it will simply toggle the dropdown (not just on click on the arrow). And i dont seem to find a way to have a difference between

            Click on Arrow
            Click on ComboBox (showing the current selected entry
            Click on Entry (when list is open)

            Guess i have to add a new button next to the combobox.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What Qt version are you using ?
              What OS are you running ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • N Offline
                N Offline
                Neko
                wrote on last edited by
                #7

                I'm using Qt 5.10 - Win10 with the Visual Studio Qt VS Tools Plugin.

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi
                  Unless you make a subclass and implement to send signal on edit click
                  im not sure its possible. There seems to be no signal for user click on edit/text part.
                  You might be able to catch it using event filter.

                  But its very uncommon to have combobox run some function if you click it
                  so i much more like you idea of an Execute button. :)

                  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