WLineEdit has wrong size

Added by Ulf Johnsson 4 months ago

Hi!
When I use WLineEdit:s they get the wrong size, if I for example resize them to (20, 40) they get
an acctual size on the screen off (26,46). The "offset" seems to always be 6px in each direction.
Is this a bug, or am I missing some secret setting ?

Regards,
Ulf Johnsson


Replies

RE: WLineEdit has wrong size - Added by Koen Deforche 4 months ago

Hey,

resize() sets a size to the inner area, excluding padding and borders (yes that's confusing but that's CSS).
The 6 bits offset you see is this padding and borders (and this is actually browser-dependent).

For the purpose of layout managers, Wt contains the methods Wt::WWidget::boxBorder() and boxPadding() which
contain these offsets.

Alternatively, in CSS3 (supported already by some browsers), you use the CSS box-sizing mode which makes
the width and height apply to the entire width including border and padding, but this will not work on
all browsers.

Regards,
koen

RE: WLineEdit has wrong size - Added by Ulf Johnsson 4 months ago

Got it working nicely with boxPadding and boxBorder :)

Thanks!