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. QWidget signal autoconnection problem
Forum Updated to NodeBB v4.3 + New Features

QWidget signal autoconnection problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 6 Posters 3.5k Views 4 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.
  • SGaistS SGaist

    Hi,

    Might be a silly question but how do you know they are not working as expected ?

    S Offline
    S Offline
    szergejbubka
    wrote on last edited by
    #3

    @SGaist The runtime message complaining about the signal indicates that it cannot connect. The slots are indeed not executed, which I checked with a qDebug message, that did not appeared in the output, and by using gdb too, in which case the breakpoint in the slot did not hit.

    jsulmJ 1 Reply Last reply
    0
    • S szergejbubka

      @SGaist The runtime message complaining about the signal indicates that it cannot connect. The slots are indeed not executed, which I checked with a qDebug message, that did not appeared in the output, and by using gdb too, in which case the breakpoint in the slot did not hit.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @szergejbubka said in QWidget signal autoconnection problem:

      The runtime message complaining about the signal indicates that it cannot connect

      It would be helpful to see this message

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      1
      • jsulmJ jsulm

        @szergejbubka said in QWidget signal autoconnection problem:

        The runtime message complaining about the signal indicates that it cannot connect

        It would be helpful to see this message

        S Offline
        S Offline
        szergejbubka
        wrote on last edited by szergejbubka
        #5

        @jsulm

        QMetaObject::connectSlotsByName: No matching signal for on_togglePlcPushButton_toggled(bool)
        

        As I said, the togglePlcPushButton QPushButton exists in the form. The same pattern is working fine for some other QWidgets in the same form. The working and not working slots are both connected by the Designer (Go to slot menu).

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

          Is it possible to grab the code somewhere to inspect it ?

          Or for you to create a minimal compilable example showing that behaviour ?

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

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

            hi
            is it the
            "QMetaObject::connectSlotsByName: No matching signal for ..." error ? (yep, you posted while writing :)

            Did you rename the widgets ?
            It works by the naming of the widgets
            setupUI calls
            QMetaObject::connectSlotsByName(MainWindow);
            like
            on_pushButton_released()

            so if you rename the button AFTER you made the slot, there is no match anymore.
            the rule is
            on_ObjectName_Signal

            If you didnt do any of that, then please delete your build folder and rebuild

            So if want to you use auto connection, you should name the widgets as you want before hooking up slots.

            1 Reply Last reply
            1
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #8

              Not only renaming: if you switched from using clicked() signal to toggled() signal, this may fail as well.

              (Z(:^

              mrjjM 1 Reply Last reply
              2
              • sierdzioS sierdzio

                Not only renaming: if you switched from using clicked() signal to toggled() signal, this may fail as well.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #9

                @sierdzio
                hi
                Like rename the slot to _toggled() or in what way switch ?
                or like adding the new slot and delete old and it complains?

                Deleting build folder should cure that or you mean something else?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  szergejbubka
                  wrote on last edited by
                  #10

                  I tried to create a smaller project, but that does not show that behavior, all those slots are connected and called.

                  I made several rebuilds, deleted all the generated files, etc, but that did not help. I used the Designer to generate those slots, and the Designer took care of the proper slot names, and I triplechecked, that the QWidgets exist in the form. I will try to switch to Qt 5.9.1, but I do not hope much from that.

                  J.HilkJ 1 Reply Last reply
                  1
                  • S szergejbubka

                    I tried to create a smaller project, but that does not show that behavior, all those slots are connected and called.

                    I made several rebuilds, deleted all the generated files, etc, but that did not help. I used the Designer to generate those slots, and the Designer took care of the proper slot names, and I triplechecked, that the QWidgets exist in the form. I will try to switch to Qt 5.9.1, but I do not hope much from that.

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #11

                    @szergejbubka
                    I would drop the use of QtCreators connectSlotsByName functionality entierly.
                    I got screwed a few times when I started with it. But since then changed to defining all my connects by hand using Qt5 syntax when possible. That way, the project won't compile if I/or something messed by Signals/Slots up.


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    S 1 Reply Last reply
                    1
                    • S Offline
                      S Offline
                      szergejbubka
                      wrote on last edited by
                      #12

                      Ok, so rebuilding with Qt 5.9.1 did not help.

                      However it seems even more mysterious. My form's layout is a grid layout, and I have several grid layouts in it. The buttons are in those grid layouts. Now I moved one of my faulty button to the outermost grid layout. The slot now connected automatically, but now I have 13 unconnected slots including the 5, that were faulty previously. The 6th (which I moved out from an inner grid layout) now works perfectly.

                      1 Reply Last reply
                      0
                      • J.HilkJ J.Hilk

                        @szergejbubka
                        I would drop the use of QtCreators connectSlotsByName functionality entierly.
                        I got screwed a few times when I started with it. But since then changed to defining all my connects by hand using Qt5 syntax when possible. That way, the project won't compile if I/or something messed by Signals/Slots up.

                        S Offline
                        S Offline
                        szergejbubka
                        wrote on last edited by
                        #13

                        @J.Hilk Yes, that is a final solution, however using the automatic connection feature is very comfortable and it worked for me for several years. Only recently started to fail. But eventually I will be forced to connect them manually.

                        1 Reply Last reply
                        0
                        • SGaistS SGaist

                          Is it possible to grab the code somewhere to inspect it ?

                          Or for you to create a minimal compilable example showing that behaviour ?

                          S Offline
                          S Offline
                          szergejbubka
                          wrote on last edited by
                          #14

                          @SGaist Maybe via teamviewer?

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            szergejbubka
                            wrote on last edited by
                            #15

                            If I move that button back to its original place either by dragging and dropping or by undoing the previous edit, there are still 13 unconnected slots. By undoing I expected to get back at least the original behavior. Something non-deterministic happens here?

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              szergejbubka
                              wrote on last edited by
                              #16

                              Furthermore if I set a stylesheet for a faulty button in the designer (red background), it appears correctly in the preview with the modified stylesheet, but it does not have any influence on the widget when I run the program. If I set the same stylesheet in the code, it appears correctly even when I run it. I suppose this is in connection with the above not connected slots, although I do not understand it, and I have no idea, what the cause could be.

                              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