[Qt-interest] How to delete the widget from the stack in Qt

Denis Akhmetzyanov dakhmetzyanov at smartlabs.tv
Wed Mar 24 12:09:44 CET 2010


Hi,
Documentation of QStackedWidget::removeWidget() has slightly confusing note:
*   Note:* The ownership of *widget* remains the same.
But implementation of QStackedWidget simply delegates removing to the
internal QStackedLayout:

void QStackedWidget::removeWidget(QWidget *widget)
{
    d_func()->layout->removeWidget(widget);
}

And description of the QLayout::removeWidget() says:
*   Note:* The ownership of *widget* remains the same as when it was added.
Therefore you should take ownership of the removed widget to yourself and
delete it manually. For example:

// QWidget *widget
stackedWidget->removeWidget(widget);
delete widget;

P.S. Documentation of Qt 4.6


2010/3/24 Ramesh <ramesh.bs at robosoftin.com>

>  Hi, i am using Qstackedwidget to switch between the views, i will be able
> to traverse between the views, i am facing problem in some scenario, where i
> do not require the widgets, i want to remove them completely.. stackedwidget
> provides the functionality to removewidgets, still the ownership of the
> widget will be there, i mean widget will be hidden.
>
> i dont want this to be happen, when i call remove widget the widget should
> be deleted. how to handle this?
>
> Thanks
>
>  -----------------------------------------------
>
> Robosoft Technologies - Come home to Technology
>
> Disclaimer: This email may contain confidential material. If you were not
> an intended recipient, please notify the sender and delete all copies.
> Emails to and from our network may be logged and monitored. This email and
> its attachments are scanned for virus by our scanners and are believed to be
> safe. However, no warranty is given that this email is free of malicious
> content or virus.
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100324/2a6c1f1b/attachment.html 


More information about the Qt-interest-old mailing list