Felix
Felix

Reputation: 7146

QWidget winId crashing if called from constructor

I'm writing a program, where i callQWidget::winId()in the constructor:

debug_window::debug_window(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::debug_window),
    hk(NULL)
{
    this->ui->setupUi(this);
    this->hk = new TestClass(this, this->winId())
}

But this will cause my program to crash, even before a window is created. I already figured out that the call of winId causes the crash, probably because at this time there is no window existing. (correct me if I'm wrong). Sadly, there is no signal "windowCreated()" or something similar. So is there any way to find out that the window was created, or how to in general solve this problem?

Thanks for your help.

Upvotes: 0

Views: 608

Answers (1)

DeadWarlock
DeadWarlock

Reputation: 720

Create signal and emit him in the end of constructor.

Upvotes: 1

Related Questions