Reputation: 67
I'm writing a program which has two dialogs. In my main dialog class I declared a pointer to the other dialog like such: ChildDialog *childDialog. However, when I try to use it for example childDialog->show() or try to use it to connect signals and slots between the two classes, my program crashes. Anyone know why? Did I declare the pointer incorrectly?
P.S. I have included the header file in the appropriate places. So I don't think that's the problem. Thanks in advance!
Upvotes: 0
Views: 187
Reputation: 9691
You need to allocate the object--
ChildDialog *childDialog;
Just declares a pointer to a ChildDialog
. No ChildDialog
is actually created so when you try to access it, you get a crash. Rather you need
ChildDialog* childDialog = new ChildDialog(...);
With arguments to the constructor as required.
Upvotes: 3