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. "Group Signal" to be emmited
Qt 6.11 is out! See what's new in the release blog

"Group Signal" to be emmited

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.5k Views 1 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.
  • D Offline
    D Offline
    DeanQt
    wrote on last edited by
    #1

    Suppose I have numerous spinbox widgets, say 10 input widgets. I then have 1 output widget.
    How do I write the signal slot connect code to make the output widget change after ANY of the input widgets are finished editing?

    So for example, for 1 specific signal, the code would be:
    @ connect (ui ->doubleSpinBox, SIGNAL (editingFinished()),this, SLOT (mySlot()));@

    Now I could do this for every input widget, like so:
    @ connect (ui ->doubleSpinBox, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_2, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_3, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_4, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_5, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_6, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_7, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_8, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_9, SIGNAL (editingFinished()),this, SLOT (mySlot()));@
    @ connect (ui ->doubleSpinBox_10, SIGNAL (editingFinished()),this, SLOT (mySlot()));@

    This is really tedious work. Can I not "group" or "family" all the input widgets into one group and make it so that if any of them are editingFinished, the output widget will change?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Skyrpex
      wrote on last edited by
      #2

      I think there isn't such a feature in Qt Creator or even in the Qt library.

      Maybe you could use "QObject::children":http://doc-snapshot.qt-project.org/qdoc/qobject.html#children and "QObject::objectName":http://doc-snapshot.qt-project.org/qdoc/qobject.html#objectName-prop to filter your widgets. For example:
      @
      for(QObject child : widget->children()) {
      if(child->objectName() == /
      some regexp here: doubleSpinBox_N */) {
      connect(child, SIGNAL(editingFinished()), this, SLOT(mySlot()));
      }
      }
      @

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cincirin
        wrote on last edited by
        #3

        For this situation you can use "QSignalMapper":http://qt-project.org/doc/qt-5/qsignalmapper.html#details

        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