void DeviceDialog::on_buttonBox_accepted()
{
colorSelect = new ColorSelect(this);
//When OK is pressed, set item data with house code and unit code
colorSelect->setItemData(ui->houseLineEdit->text(), ui->unitLineEdit->text());
delete colorSelect;
}
void DeviceDialog::on_buttonBox_accepted()
{
colorSelect = new ColorSelect(this);
//When OK is pressed, set item data with house code and unit code
colorSelect->setItemData(ui->houseLineEdit->text(), ui->unitLineEdit->text());
delete colorSelect;
}
To copy to clipboard, switch view to plain text mode
No, no, no, you do not want this. This is equivalent to a NO-OP - you create the class instance on the stack, do something with it, and it immediately gets deleted along with whatever you did.
Unfortunately, you cannot create an instance of ColorSelect in the DeviceDialog constructor if you also create an instance of DeviceDialog in the ColorSelect constructor. That sets up an infinite recursion: ColorSelect creates DeviceDialog which creates ColorSelect which creates DeviceDialog ad infinitum until your stack blows up.
BUT I am not at all sure that this code does what you intend in your app. Even if you work around the recursion problem, you will still end up with independent instances of each class, instead of one instance of ColorSelect and one instance of DeviceDialog. Changes made to one instance of either class will be local to that instance only, so for example changing something in the list widget of one DeviceDialog won't have any effect on the list widget in other instances.
Maybe you can show some code on how you create and use these classes and we can give you some advice on how to structure the dependencies between them.
Bookmarks