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. Multiple windows signal slot problem
Qt 6.11 is out! See what's new in the release blog

Multiple windows signal slot problem

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 3.9k 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
    wrote on last edited by
    #2

    connect only connects the signal and slots. You need to use the emit keyword to send the signal.

    if the signal name is 'colorSelected' you should send the signal using

    emit colorSelected(color)

    Once you do this above slot will be called.

    Dheerendra
    @Community Service
    Certified Qt Specialist
    https://www.pthinks.com

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

      Hi and welcome to devnet,

      Since "d" looks like it's created on the stack, are you sure it exists long enough to actually send the signal ?

      Just to correct Dheerendra, you can also connect signals to signals. It's called signal forwarding. Not necessarily useful in this precise case but might be in the future.

      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
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
        wrote on last edited by
        #4

        Yes, Signal to Signal connect also can be used. What I meant in the above post was that, connect does not emit signal. It only connects. If he is assuming that it automatically emits signal it will be potential issue.

        I think 'd' and 'bargraph' as stack variable are good observation from Galst. I feel this could be potential problem in your case. Make them as heap variables.

        d = new classD
        bargraph = new BarGraph.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        https://www.pthinks.com

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #5

          [quote author="Dheerendra" date="1389781569"]Yes, Signal to Signal connect also can be used. What I meant in the above post was that, connect does not emit signal. It only connects. If he is assuming that it automatically emits signal it will be potential issue.

          I think 'd' and 'bargraph' as stack variable are good observation from Galst. I feel this could be potential problem in your case. Make them as heap variables.

          d = new classD
          bargraph = new BarGraph.

          [/quote]

          Thanks a lot Dheerendra.

          I checked the use of "emit" and wote
          @emit d.colorSelected(bar_color);@

          But colorSelected(const QColor &) is a protected signal of QColorDialog. So it won't work if I wrote it in this way?
          Could you please give me some further suggestions?

          Many thanks!

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

            You can't emit a signal from another class

            QColorDialog will emit the signal when needed

            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
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #7

              [quote author="SGaist" date="1389779303"]Hi and welcome to devnet,

              Since "d" looks like it's created on the stack, are you sure it exists long enough to actually send the signal ?

              Just to correct Dheerendra, you can also connect signals to signals. It's called signal forwarding. Not necessarily useful in this precise case but might be in the future.

              [/quote]
              Thank you very much SGaist!

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #8

                [quote author="SGaist" date="1389789056"]You can't emit a signal from another class

                QColorDialog will emit the signal when needed[/quote]

                Thanks a lot SGaist, it is because the "stack", I changed the position of the "connect" and it works now.

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

                  What do you mean by: "changed the position of the connect" ?

                  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
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #10

                    [quote author="SGaist" date="1389876303"]What do you mean by: "changed the position of the connect" ?[/quote]

                    Just right after the declaration of d

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

                      Looks like you might be doing something unusual with your code, can you post it ?

                      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

                      • Login

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