Project

General

Profile

Actions

Support #3750

closed

How do I grab the dimensions of a WPaintedWidget to draw a line with them?

Added by Mikey Nosihcan about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
02/02/2015
Due date:
% Done:

0%

Estimated time:

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?

Actions #1

Updated by Mikey Nosihcan about 9 years ago

This is posted in features - should be removed from bugs.

Actions #2

Updated by Wim Dumon about 9 years ago

  • Status changed from New to Resolved

Hello,

Any widget can have the size set by a layout manager reported as follows:

  1. set setLayoutSizeAware(true) for the widget
  2. reimplement layoutSizeChanged(int width, int height)

BR,

Wim.

Actions #3

Updated by Mikey Nosihcan about 9 years ago

WLineF does not inherit from WWidget and has no setLayoutSizeAware() method. Perhaps I'm misunderstanding something....

Actions #4

Updated by Wim Dumon about 9 years ago

But WPaintedWidget does...

Wim.

Actions #5

Updated by Mikey Nosihcan about 9 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

Actions #6

Updated by Koen Deforche about 9 years ago

  • Tracker changed from Bug to Support
  • Assignee set to Wim Dumon
Actions #7

Updated by Koen Deforche about 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF