WContainerWidget->setAttribute() remove widget width and height

Added by Cemal DEMİR over 1 year ago

While construct WContainerWidget, setAttribute("style",someAttributes...); works well

but when recall setAttribute at somewhere after constructed, Widget's width and height are removed. so Widget width and height were going to be 0px*0px in browser. it can not be visible.

is it bug?

Replies (1)

RE: WContainerWidget->setAttribute() remove widget width and height - Added by Matthias Van Ceulebroeck 16 days ago

Hello Cemal,

I am going over older unresolved things, so I apologize if I bother you with an email.

This is not strictly a bug, rather expected behavior. Once the widget is rendered, it will have certain properties assigned to it. If you call setAttributeValue(attribute, value) this will SET the attribute to the specified value. It does not keep track of the existing value. To do this, you'd need to call attributeValue(attribute) first, and append that to the new value (and check for potential duplicates.

This functions similarly to setStyleClass which removes all existing classes, and adds (a) new class(es). Whereas addStyleClass appends it to the list.
We do not offer such functionality, since not all attributes are formatted the same way, or function the same way, and thus a central approach like for the style classes is not possible.