Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

why? it shows me these warnings when I generate the slots for my controls.



  • Hello friends, I have the following problem in my code, it happens that when I generate the slots corresponding to some widgets, I always get these warnings, and I have no idea why it is, I would appreciate any suggestion of how I could solve it, and if in the future this may blow up in my face, thanks in advance.

    270d8ba2-8072-48fe-b699-58c26c5305a8-image.png



  • These slots are named to take advantage of automatic connections between signals and slots implemented by QMetaObject::connectSlotsByName() and most often used in Qt Designer UIs. This mechanism is not inherently evil. However, if you rename the object in the Designer UI and not the matching slot then the automatic connection will not happen (silently). Conversely (and less likely), if you name a function on_blah_triggered() for a reason unrelated to the UI, but where blah exists and has a triggered() signal, you may find an unexpected connection is made (silently). You will find these at run time. This fragility is the reason for the warning.

    The alternative is to avoid the automatic connection naming and explicitly code connections in your constructor. If you use new-style connect() then this will fail at compile time in the first case, and the connection will not be present in the second.


Log in to reply