简体   繁体   English

构造函数完成后,如何立即销毁从QWindow对象派生的?

[英]How to destroy derived from QWindow object immediately after constructor done?

I need to destroy derived from QWindow object immediately after constructor done if some conditions in constructor will be true. 如果构造函数中的某些条件为真,则需要在构造函数完成后立即销毁从QWindow对象派生的对象。

There is member variable which I want to set in constructor and check in window initializing function. 我要在构造函数中设置成员变量,并在窗口初始化函数中签入。 But I don't know which function or signal is suitable for this. 但是我不知道哪个功能或信号适合于此。

You can use QObject::deleteLater() to safely delete your object. 您可以使用QObject :: deleteLater()安全删除您的对象。 Just call it in your constructor when the condition is true : 条件为true时,只需在构造函数中调用它即可:

if(condition)
{
   this->deleteLater();
   return;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM