本文整理汇总了C++中QObject::disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ QObject::disconnect方法的具体用法?C++ QObject::disconnect怎么用?C++ QObject::disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QObject
的用法示例。
在下文中一共展示了QObject::disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finishedThread
void Client::finishedThread()
{
QObject * sender = QObject::sender();
sender->disconnect();
delete sender;
}
示例2: preambleClear
void LatexDocument::preambleClear(QQmlListProperty<LatexCodeBlock> *list)
{
LatexDocument *doc = qobject_cast<LatexDocument*>(list->object);
if(doc) {
while(doc->_blocks.count() > 0) {
QObject* obj = doc->_preamble.takeLast();
obj->disconnect(doc);
}
}
}
示例3: main
int main() {
QObject* myObject = new QObject();
QObject* receiver = new QObject();
// disconnect everything from myObject
QObject::disconnect(myObject, 0, 0, 0);
myObject->disconnect(); // same as this
// myObject->disconnect(0); // ambiguous!
// myObject->disconnect(0, 0); // ambiguous!
myObject->disconnect(0, 0, 0); // and this
// disconnect everything from myObject::objectNameChanged
QObject::disconnect(myObject, &QObject::objectNameChanged, 0, 0);
QObject::disconnect(myObject, &QObject::objectNameChanged, Q_NULLPTR, Q_NULLPTR); // same as this
QObject::disconnect(myObject, &QObject::objectNameChanged, 0, Q_NULLPTR); // and this
QObject::disconnect(myObject, &QObject::objectNameChanged, 0, 0); // and this
// disconnect everything from myObject connected to receiver
QObject::disconnect(myObject, 0, receiver, 0);
myObject->disconnect(receiver); // same as this
myObject->disconnect(0, receiver); // and this
myObject->disconnect(0, receiver, 0); // and this
//disconnect everything from myObject::objectNameChanged connected to receiver
QObject::disconnect(myObject, &QObject::objectNameChanged, receiver, 0);
QObject::disconnect(myObject, &QObject::objectNameChanged, receiver, Q_NULLPTR); // same as this
// disconnect everything from myObject connected to receiver::deleteLater
// TODO: contribute a patch to Qt to allow passing null as second argument
QObject::disconnect(myObject, static_cast<void(QObject::*)()>(0), receiver, &QObject::deleteLater);
QObject::disconnect(myObject, static_cast<void(QObject::*)()>(Q_NULLPTR), receiver, &QObject::deleteLater); // same as this
QObject::disconnect(myObject, static_cast<void(QObject::*)()>(0), receiver, &QObject::deleteLater); // and this
// disconnect everything from myObject::objectNameChanged connected to receiver::deleteLater
QObject::disconnect(myObject, &QObject::objectNameChanged, receiver, &QObject::deleteLater);
QObject::disconnect(myObject, &QObject::objectNameChanged, receiver, &QObject::deleteLater); // same as this
return 0;
}