Tag Archives: Slots named on_foo_bar are error prone

[Solved] QT Warning: Slots named on_foo_bar are error prone

Problem phenomenon:

Cause:
this warning appears because when processing the signal slot relationship, we use “go-to slot” in the UI designer to make the program generate automatically
the weakness of this automatic generation is that one day, you may change the name of the control in the UI designer, but the compilation will not report an error. The program still runs normally, and the compilation does not prompt errors
in this way, the control is equivalent to not being connected to the slot function and becomes invalid.

Recommended solution:
recommendation 1: do not automatically generate signal slot connection through “go to slot” of UI designer. The relationship can be established manually. For example:
connect (toolbutton, & QPushButton:: clicked,
this, & yourclassname:: nameofyourslot)
recommendation 1: ignore this warning and just ignore it. Because this is just a kind reminder.