Support #3750
closedHow do I grab the dimensions of a WPaintedWidget to draw a line with them?
0%
Description
Using C 11 on Ubuntu 14.04, default GCC tool chain 4.9x:
I want to draw a line at the bottom of a WPaintedWidget
- call it Wt::WLineF* mXLine
- and set the position of mXline dynamically at runtime - not hard-coded. The WPaintedWidget is inside a layout manager - it gets sized automatically - I don't have to call resize()
. I want to do the same with mXLine.
In the WPaintedWidget::paintEvent()
event handler, I have tried:
mXLine = new WLineF( 0, height( ).Pixel, width( ).Pixel, height( ).Pixel );
and
mXLine = new WLineF( 0, this->parent( )->height( ).Pixel, parent( )->width( ).Pixel, parent( )->height( ).Pixel );
All the pen and painter properties are set correctly - I use them in many places - ( @ pen.width() == 5@ )- . But I get no line and in my debugger mXLine.width()
returns 1 and mXLine.height()
returns 2.
How do I get this to work?
Updated by Mikey Nosihcan almost 10 years ago
This is posted in features - should be removed from bugs.
Updated by Wim Dumon almost 10 years ago
- Status changed from New to Resolved
Hello,
Any widget can have the size set by a layout manager reported as follows:
- set setLayoutSizeAware(true) for the widget
- reimplement layoutSizeChanged(int width, int height)
BR,
Wim.
Updated by Mikey Nosihcan almost 10 years ago
WLineF does not inherit from WWidget
and has no setLayoutSizeAware()
method. Perhaps I'm misunderstanding something....
Updated by Mikey Nosihcan almost 10 years ago
OK - so you mean call setLayoutSizeAware(true)
for the WPaintedWidget
then set the position of the line in layoutSizeChanged(int width, int height)
using the width and height arguments that get passed in.
Understood.
Tnx
Updated by Koen Deforche over 9 years ago
- Tracker changed from Bug to Support
- Assignee set to Wim Dumon
Updated by Koen Deforche over 9 years ago
- Status changed from Resolved to Closed