Qt signal with an enum as a parameter

前端 未结 3 758
不思量自难忘°
不思量自难忘° 2021-01-22 02:02

I\'m trying to pass an enum as a value to a slot in my program, but I\'m having some problems. In my header file I\'ve created the enum:

Q_ENUMS(button_type);
e         


        
3条回答
  •  时光取名叫无心
    2021-01-22 03:07

    Object::connect: No such slot main_application::input_handler(button_back)
    

    Of course, there is, because signature is main_application::input_handler(button_type), and button_back is a value, not type. And even you make right signature, you will not be able to connect that signal and slot due to their signature mismatch.

    Also, you can always use QObject::sender() function to get known, what button was pressed.

提交回复
热议问题