cancel
Showing results for 
Search instead for 
Did you mean: 

Add/Remove vs SetVisible(true/false)

GMeur
Senior

Hello,

Imagine I've got an object, say a numpad, that I want to display or hide upon a specific button press.

What are the pros and cons of using one method vs the other? I'm especially asking in terms of performance as keeping the object added but hidden allows to do a partial redraw (object.invalidate()).

Should add/remove only be used when we wish to change the Z-order of the object?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

What is "one method" and what is "the other" here ?

If something is hidden, it's not drawn and does not incur any penalties. Showing hiding things is perfectly fine. I'm now guessing that you mean "what are the pros and cons of hiding vs REMOVING an element from the root container" ?

The only reason you'd remove something is to place it differently in the "tree" of widgets (z-order).

/Martin

View solution in original post

1 REPLY 1
Martin KJELDSEN
Chief III

What is "one method" and what is "the other" here ?

If something is hidden, it's not drawn and does not incur any penalties. Showing hiding things is perfectly fine. I'm now guessing that you mean "what are the pros and cons of hiding vs REMOVING an element from the root container" ?

The only reason you'd remove something is to place it differently in the "tree" of widgets (z-order).

/Martin