当前位置: 首页>>代码示例>>C++>>正文


C++ QObject::disconnect方法代码示例

本文整理汇总了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;
}
开发者ID:gonboy,项目名称:evcc,代码行数:7,代码来源:client.cpp

示例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);
		}
	}
}
开发者ID:featureNull,项目名称:QMLaTex,代码行数:10,代码来源:LatexDocument.cpp

示例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;
}
开发者ID:RichardsonAlex,项目名称:convert2qt5signalslot,代码行数:38,代码来源:disconnect-Q_NULLPTR.cpp


注:本文中的QObject::disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。