C++ / Qt Class Initialization
I'm new to C++ and I'm trying to find the proper way to initialize this
class.
Here is the code:
void NewDialog::createNew()
{
InkSpot *ink;
ink = new InkSpot(this);
InkPuppet *puppet;
puppet->ui->canvas->addWidget(ink->widget);
close();
}
Now, for InkSpot *ink; & ink = new InkSpot(this); it works fine because I
actually DO need a new InkSpot created.
But I do not need a new InkPuppet *puppet created, I simply need to refer
to it's UI. Using the above code
puppet->ui->canvas->addWidget(ink->widget); causes the program to crash
because it is not being initialized.
The whole issue here is, that to initialize a new class I know how to do
it, but initializing a pre-existing class I'm not sure how to refer to it.
Thanks
No comments:
Post a Comment