[Qt-creator] What is the correct way of removing UI elements with code ?

Coda Highland chighland at gmail.com
Wed Oct 10 17:38:46 CEST 2012


On Wed, Oct 10, 2012 at 7:51 AM, Patryk Małek <malekpatryk at gmail.com> wrote:
> Hello,
>
> I have just encountered a problem, where I do not need a certain UI element
> e.g. QPushButton and I would like to remove it but since I have connected it
> with several slots (e.g. clicked(), released() etc. ) I now have several
> references of this button in my code.
>
> How can I remove all of this efficiently ? Do I have to remove it all
> manually ?
>
>
>
> kind regards,
> Patryk Małek
>
>
>
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
>

Two things.

(1) This is a question for qt-interest; this list is for issues
concerning the IDE itself, not the toolkit.

(2) If signal connections are the only references you have, there's no
concern -- QObjects (QPushButton is one, of course) disconnect
themselves from everything automatically on delete. If you have other
pointers hanging around, consider QPointer; this is Qt's smart pointer
class that automatically zeroes itself when its referent is deleted.

/s/ Adam



More information about the Qt-creator mailing list