Re: [Interest] geometry() for a widget that hasn't been shown

2015-09-23 Thread John Weeks
Thanks, André.

I had considered that but was having trouble with the retching feeling in my 
stomach. I may just do that after taking some dramamine!

-John Weeks
WaveMetrics, Inc.

> On Sep 23, 2015, at 1:00 AM, André Somers  wrote:
> 
> In the past, I have resorted to first showing the window off-screen, 
> getting its measurements, do my thing, and only then move it to the 
> visible area of the screen. It works, but it is a drag. In my case it 
> was needed in order to make a dialog that nicely resizes using an 
> animation when different options are selected.
> 


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] geometry() for a widget that hasn't been shown

2015-09-23 Thread André Somers
Op 21-9-2015 om 19:33 schreef John Weeks:
> If this is a repeat, my apologies. I can't tell if I saw this arrive on the 
> list!
>
>
>
> In general a QWidget that hasn't been made visible yet gives bogus results 
> for QWidget::geometry(). Qt only guarantees that a call to setGeometry() will 
> result in a Resize event when the window is made visible. But we often need 
> to ask a window or child widget how big it is before it is made visible in 
> order to do various kinds of calculations. These calculations are sometimes 
> used for things that preclude waiting for the window to become visible.
>
> Is there a way to force the Resize events (and all the layout calculation 
> machinery that goes with it) before it is visible? Using Qt 5.5, I see that 
> if you call QWidget::grab(), it will call a static function 
> sendResizeEvents() that does exactly what I want:
>
> QPixmap QWidget::grab(const QRect &rectangle)
> {
> Q_D(QWidget);
> if (testAttribute(Qt::WA_PendingResizeEvent) || 
> !testAttribute(Qt::WA_WState_Created))
> sendResizeEvents(this);
>
> Is there some other way to get this to happen? I suppose I could just call 
> grab() and throw away the QPixmap, but that seems like an awful kludge...
>
In the past, I have resorted to first showing the window off-screen, 
getting its measurements, do my thing, and only then move it to the 
visible area of the screen. It works, but it is a drag. In my case it 
was needed in order to make a dialog that nicely resizes using an 
animation when different options are selected.

André

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] geometry() for a widget that hasn't been shown

2015-09-22 Thread John Weeks
Thanks, Jan. I thought the same thing, but it didn't help. I even called 
EnsurePolished() first, having seen such things in the Qt source. But it 
appears that adjustSize() adjusts child widgets for the current window 
geometry, and doesn't try to determine an accurate window geometry first.

The fundamental problem is that Qt puts off creating the native window 
representation (NSWindow or NSView or HWND, etc.) until it is first shown. So 
until then, there is nothing to measure.

But it does seem as though the cached geometry could be used to return an 
accurate value. I guess its JIRA bug time...

-John Weeks


> On Sep 22, 2015, at 4:31 AM, Jan Dasselaar  wrote:
> 
> Maybe the QWidget::adjustSize() function is what you are looking for.
> I think after calling adjustSize() the geometry() function should give a 
> up to date result.

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] geometry() for a widget that hasn't been shown

2015-09-22 Thread Jan Dasselaar
Hello John,

Maybe the QWidget::adjustSize() function is what you are looking for.
I think after calling adjustSize() the geometry() function should give a 
up to date result.

Hth,
Jan

On 21-9-2015 19:33, John Weeks wrote:
> If this is a repeat, my apologies. I can't tell if I saw this arrive on the 
> list!
>
>
>
> In general a QWidget that hasn't been made visible yet gives bogus results 
> for QWidget::geometry(). Qt only guarantees that a call to setGeometry() will 
> result in a Resize event when the window is made visible. But we often need 
> to ask a window or child widget how big it is before it is made visible in 
> order to do various kinds of calculations. These calculations are sometimes 
> used for things that preclude waiting for the window to become visible.
>
> Is there a way to force the Resize events (and all the layout calculation 
> machinery that goes with it) before it is visible? Using Qt 5.5, I see that 
> if you call QWidget::grab(), it will call a static function 
> sendResizeEvents() that does exactly what I want:
>
> QPixmap QWidget::grab(const QRect &rectangle)
> {
> Q_D(QWidget);
> if (testAttribute(Qt::WA_PendingResizeEvent) || 
> !testAttribute(Qt::WA_WState_Created))
> sendResizeEvents(this);
>
> Is there some other way to get this to happen? I suppose I could just call 
> grab() and throw away the QPixmap, but that seems like an awful kludge...
>
> -John Weeks
>
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] geometry() for a widget that hasn't been shown

2015-09-21 Thread John Weeks
If this is a repeat, my apologies. I can't tell if I saw this arrive on the 
list!



In general a QWidget that hasn't been made visible yet gives bogus results for 
QWidget::geometry(). Qt only guarantees that a call to setGeometry() will 
result in a Resize event when the window is made visible. But we often need to 
ask a window or child widget how big it is before it is made visible in order 
to do various kinds of calculations. These calculations are sometimes used for 
things that preclude waiting for the window to become visible.

Is there a way to force the Resize events (and all the layout calculation 
machinery that goes with it) before it is visible? Using Qt 5.5, I see that if 
you call QWidget::grab(), it will call a static function sendResizeEvents() 
that does exactly what I want:

QPixmap QWidget::grab(const QRect &rectangle)
{
   Q_D(QWidget);
   if (testAttribute(Qt::WA_PendingResizeEvent) || 
!testAttribute(Qt::WA_WState_Created))
   sendResizeEvents(this);

Is there some other way to get this to happen? I suppose I could just call 
grab() and throw away the QPixmap, but that seems like an awful kludge...

-John Weeks

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] geometry() for a widget that hasn't been shown

2015-09-18 Thread John Weeks
In general a QWidget that hasn't been made visible yet gives bogus results for 
QWidget::geometry(). Qt only guarantees that a call to setGeometry() will 
result in a Resize event when the window is made visible. But we often need to 
ask a window or child widget how big it is before it is made visible in order 
to do various kinds of calculations. These calculations are sometimes used for 
things that preclude waiting for the window to become visible.

Is there a way to force the Resize events (and all the layout calculation 
machinery that goes with it) before it is visible? Using Qt 5.5, I see that if 
you call QWidget::grab(), it will call a static function sendResizeEvents() 
that does exactly what I want:

 QPixmap QWidget::grab(const QRect &rectangle)
{
Q_D(QWidget);
if (testAttribute(Qt::WA_PendingResizeEvent) || 
!testAttribute(Qt::WA_WState_Created))
sendResizeEvents(this);

Is there some other way to get this to happen? I suppose I could just call 
grab() and throw away the QPixmap, but that seems like an awful kludge...

-John Weeks

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest