Sunday, January 24, 2010

"QMetaObject::connectSlotsByName: No matching signal for ..." Qt GUI Warning Message

If you get an error message (warning actually) like this:
QMetaObject::connectSlotsByName: No matching signal for on_MainWindow_destroyed()

It means you have an automatically named slot method in the main window or top-level widget.

Qt will automatically connect slots for child widgets, but not the top-level widget.

To solve this problem, you need to:
  1. Rename the slot so it doesn't start with "on_"
  2. Manually connect the slot.
connect(this, SIGNAL(destroyed()), this, SLOT(handle_MainWindow_destroyed()));

I've reported this as Qt Designer bug QT-7582.

References:

7 comments:

  1. Thanks buddy! you helped me :-)

    It's really stupid that having "on_" at the beginning would mess with the compiler! this is really weird C++!!!

    ReplyDelete
  2. thanks! you solved my problem too!
    Andrea

    ReplyDelete
  3. :) Incredible...thank you very much!!

    ReplyDelete
  4. wow this is quite stupid... :)
    Thank you once again!

    ReplyDelete
  5. thank you >___<
    you solve my problem!!

    ReplyDelete

Be the first to comment!