开发者

How to delete a widget from a stacked widget in Qt

Using QStackedWidget to switch between the views, I will be able to traverse between the views.

I am facing problem in some scenarios, where I do not require the widgets, but I want to remove them completely.

QStackedWidget provides the functionality to remove widgets, still the ownership of the widget will be there, I mean widget will be hidden.

I don't want this to be happen - when I call remove widget it should be d开发者_如何学JAVAeleted. How should I handle this?


Have you tried simply deleting the object after removing it? i.e.

stackWidget->removeWidget(myWidget);
delete myWidget;


Many Qt objects will get automatically removed when deleted. (At least, in the QtGraphics API things work that way) I suspect that simply deleting the object will also remove it, since Qt Objects do emit a signal that they have been deleted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜