Qt Designer, missing “go to slot” in context menu?

前端 未结 1 1645
北恋
北恋 2020-12-19 16:06

I\'ve been watching a Qt tutorial series on YouTube, in which the author shows how to call a function, when a button is pressed. He right-clicked on the button in Qt Creator

相关标签:
1条回答
  • 2020-12-19 16:29

    While I don't know why the QtDesigner in Netbeans doesn't provide this feature, I know what the feature does: It just creates a slot with a special name in your widget class. Note that it does not add a connect statement. It uses the automatic connection feature, which works like this:

    For each slot which name matches this pattern:

    void on_X_Y(...)

    it will be connected to the signal named Y of the object named X. So if you have a QPushButton named button, and you want to handle the signal pressed, simply create a slot with the following signature:

    void on_button_pressed()

    If you wonder how this slot gets connected to the signal: This happens in the ui_...h file at the end of setupUi():

        QMetaObject::connectSlotsByName(WidgetName);
    
    0 讨论(0)
提交回复
热议问题