我对QT和PyQT有一个初学者的问题。
我正在使用Python的PyQt绑定(bind),并具有以下简单代码。根据一些Google搜索,似乎槽口装饰器主要用于显式标记槽口的方法。我的问题是,如果我要用C++编写此代码,那么等效的方法是什么?
@QtCore.pyqtSlot()
def openDialog(self):
self.myDialog.show()
最佳答案
要在C++ / Qt中创建插槽,请使用以下语法:
class MyClass : public QObject {
Q_OBJECT
public slots:
void mySlot(/* parameters here */); // Definition may be here or in the implementation file
};
如果您使用no_keywords选项(这意味着您不想将Qt关键字用作普通的C++关键字),只需将
slots
替换为Q_SLOTS
您可以在官方文档中找到更多信息:http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html
关于c++ - pyQT插槽装饰器是什么C++等效项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18833471/