Hello,
I have an issue with Qt layout.
That piece of code is working :
ZeTextWidget * textWidget = new ZeTextWidget ("Salut"); // Creating a new Widget
ZeTopListWidget * topListWidget1 = new ZeTopListWidget(*textWidget); // Adding the widget to the layout
topListWidget1->Clear(); // Clearing the object / layout
delete topListWidget1; // Deleting the object containing the layout
ZeTextWidget * textWidget = new ZeTextWidget ("Salut"); // Creating a new Widget
ZeTopListWidget * topListWidget1 = new ZeTopListWidget(*textWidget); // Adding the widget to the layout
topListWidget1->Clear(); // Clearing the object / layout
delete topListWidget1; // Deleting the object containing the layout
To copy to clipboard, switch view to plain text mode
That one isn't :
ZeTextWidget textWidget("Salut"); // Creating a local variable
ZeTopListWidget * topListWidget1 = new ZeTopListWidget(textWidget); // Adding the widget to the layout
topListWidget1->Clear(); // Clearing the object / layout
delete topListWidget1; // Deleting the object containing the layout
ZeTextWidget textWidget("Salut"); // Creating a local variable
ZeTopListWidget * topListWidget1 = new ZeTopListWidget(textWidget); // Adding the widget to the layout
topListWidget1->Clear(); // Clearing the object / layout
delete topListWidget1; // Deleting the object containing the layout
To copy to clipboard, switch view to plain text mode
When creating my "ZeTopListWidget " I'm doing this :
mLayout.addWidget(&widget);
mWidget = &widget;
mLayout.addWidget(&widget);
mWidget = &widget;
To copy to clipboard, switch view to plain text mode
When clearing my "ZeTopListWidget" I'm doing this :
if (mWidget)
{
mLayout.removeWidget(mWidget);
mWidget = NULL;
}
if (mWidget)
{
mLayout.removeWidget(mWidget);
mWidget = NULL;
}
To copy to clipboard, switch view to plain text mode
When I'm:
- Adding an allocated variable to the layout.
- Clearing the layout (removeWidget).
- Deleting the object containing the layout.
-> It Works.
BUT if I'm:
- Adding a local variable to the layout.
- Clearing the layout (removeWidget).
- Deleting the object containing the layout.
-> Crash on the delete line.
Obviously something is going wrong when the Layout default dtor is called.
Provided the fact that I remove the assigned widget before deleting my object and thus its member's layout: it should work fine.
Is there something I'm missing ?
Bookmarks