Re: Layout sizeHint weird behavior
Brought to you by:
rathmann
From: Uwe R. <Uwe...@ti...> - 2024-08-09 12:25:20
|
On 8/8/24 10:10, Giacomo S wrote: > Well, printing the list of major ticks, *before* the default scale > bounds are set from 0 to 1000 with 6 major ticks, this is what I get: > > QwtPlot.sizeHint: Y axis ticks: 0.000000, 10.000000, 20.000000, > 30.000000, 40.000000, 50.000000, 60.000000, 70.000000, 80.000000, > 90.000000, 100.000000, The default setting of QwtScaleWidget is [0,100]. > I think there is something (temporarily) wrong in the initialization of > the scales. Well the size hints of the plot depends on the hints from the scales and the hint of a scale depend on its ticks. The ticks are set in QwtPlot::updateAxes, what can be called explicitly or implicitly from replot. So yes - the size hint of the plot is not updated before updateAxes has been called. But note, that any QWidget has to indicate changes of its size hint by posting a QEvent::LayoutRequest. This might be done by QWidget::updateGeometry() or manually like in QwtPlot::replot. When working with Qt layouts the event should be handled by them. If not you could implement an event handler in the parent of your plot widget. HTH, Uwe |