Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, April 2007
RE: Qt 4.2 (Windows) - workaround for window geometry shift? (wi ndowcreeps upward)


Message 1 in thread

How do you save it and load it?

I do it like that in my QMainWindow and have no problem:
QSettings Settings(Whatever...)
Settings.setValue("pos", pos());
Settings.setValue("size", size());

and then load like
QPoint Point = Settings->value("pos").toPoint();
if (Point.x() < 1 || Point.y() < 1) {
	Point.setX(DEFAULT_GUI_POS_X);
	Point.setY(DEFAULT_GUI_POS_Y);
}

QSize Size = Settings->value("size").toSize();
if (Size.height() < 1 || Size.width() < 1) {
	Size.setHeight(DEFAULT_GUI_SIZE_X);
	Size.setWidth(DEFAULT_GUI_SIZE_Y);
}

move(Point);
resize(Size);

Sandor


-----Original Message-----
From: Paul Miller [mailto:paul@xxxxxxxxxx]
Sent: 05/04/2007 16:17
To: QT Interest List
Subject: Qt 4.2 (Windows) - workaround for window geometry shift?
(windowcreeps upward)


I see that if you do what the docs suggest to save/restore the window 
geometry, on Windows, each time you restore the geometry, the window 
shifts up by the titlebar height, and left by the frame width.

Looks like the saved window geometry includes the window frame, but 
restoring the geometry does NOT take into account the frame.

I'll report a bug, but is there a workaround for this?

-- 
 [ signature omitted ] 

Message 2 in thread

Hadas Sandor wrote:
> How do you save it and load it?
> 
> I do it like that in my QMainWindow and have no problem:
> QSettings Settings(Whatever...)
> Settings.setValue("pos", pos());
> Settings.setValue("size", size());
> 
> and then load like
> QPoint Point = Settings->value("pos").toPoint();
> if (Point.x() < 1 || Point.y() < 1) {
> 	Point.setX(DEFAULT_GUI_POS_X);
> 	Point.setY(DEFAULT_GUI_POS_Y);
> }
> 
> QSize Size = Settings->value("size").toSize();
> if (Size.height() < 1 || Size.width() < 1) {
> 	Size.setHeight(DEFAULT_GUI_SIZE_X);
> 	Size.setWidth(DEFAULT_GUI_SIZE_Y);
> }
> 
> move(Point);
> resize(Size);

I've tried it like that, also by calling geometry()/setGeometry(), 
saveGeometry()/restoreGeometry(). All cause the windows to shift up/left.

The only solution I could come up with is to also save the frameGeometry 
(which seems to be shifted up/left too much), and then add on the 
difference between the geometry and the frameGeometry.

As I mentioned, I believe this is a WINDOWS ONLY problem.

But storing the geometry and then restoring it definitely causes problems.

> 
> Sandor
> 
> 
> -----Original Message-----
> From: Paul Miller [mailto:paul@xxxxxxxxxx]
> Sent: 05/04/2007 16:17
> To: QT Interest List
> Subject: Qt 4.2 (Windows) - workaround for window geometry shift?
> (windowcreeps upward)
> 
> 
> I see that if you do what the docs suggest to save/restore the window 
> geometry, on Windows, each time you restore the geometry, the window 
> shifts up by the titlebar height, and left by the frame width.
> 
> Looks like the saved window geometry includes the window frame, but 
> restoring the geometry does NOT take into account the frame.
> 
> I'll report a bug, but is there a workaround for this?
> 


-- 
 [ signature omitted ] 

Message 3 in thread

Hi,
Do you use a style for this app?

I ask this because I descovered bugs that was only present for a style.
for example, a sizehint problem occured in a combobox only when I 
applied cleanslooks style to the app
?......



Paul Miller a écrit :

> Hadas Sandor wrote:
>
>> How do you save it and load it?
>>
>> I do it like that in my QMainWindow and have no problem:
>> QSettings Settings(Whatever...)
>> Settings.setValue("pos", pos());
>> Settings.setValue("size", size());
>>
>> and then load like
>> QPoint Point = Settings->value("pos").toPoint();
>> if (Point.x() < 1 || Point.y() < 1) {
>>     Point.setX(DEFAULT_GUI_POS_X);
>>     Point.setY(DEFAULT_GUI_POS_Y);
>> }
>>
>> QSize Size = Settings->value("size").toSize();
>> if (Size.height() < 1 || Size.width() < 1) {
>>     Size.setHeight(DEFAULT_GUI_SIZE_X);
>>     Size.setWidth(DEFAULT_GUI_SIZE_Y);
>> }
>>
>> move(Point);
>> resize(Size);
>
>
> I've tried it like that, also by calling geometry()/setGeometry(), 
> saveGeometry()/restoreGeometry(). All cause the windows to shift up/left.
>
> The only solution I could come up with is to also save the 
> frameGeometry (which seems to be shifted up/left too much), and then 
> add on the difference between the geometry and the frameGeometry.
>
> As I mentioned, I believe this is a WINDOWS ONLY problem.
>
> But storing the geometry and then restoring it definitely causes 
> problems.
>
>>
>> Sandor
>>
>>
>> -----Original Message-----
>> From: Paul Miller [mailto:paul@xxxxxxxxxx]
>> Sent: 05/04/2007 16:17
>> To: QT Interest List
>> Subject: Qt 4.2 (Windows) - workaround for window geometry shift?
>> (windowcreeps upward)
>>
>>
>> I see that if you do what the docs suggest to save/restore the window 
>> geometry, on Windows, each time you restore the geometry, the window 
>> shifts up by the titlebar height, and left by the frame width.
>>
>> Looks like the saved window geometry includes the window frame, but 
>> restoring the geometry does NOT take into account the frame.
>>
>> I'll report a bug, but is there a workaround for this?
>>
>
>

--
 [ signature omitted ] 

Message 4 in thread

veronique.lefrere@xxxxxx wrote:
> Hi,
> Do you use a style for this app?

Yes, I am using a custom style. It is derived from WindowsXPStyle.

> I ask this because I descovered bugs that was only present for a style.
> for example, a sizehint problem occured in a combobox only when I 
> applied cleanslooks style to the app
> ?......
> 
> 
> 
> Paul Miller a écrit :
> 
>> Hadas Sandor wrote:
>>
>>> How do you save it and load it?
>>>
>>> I do it like that in my QMainWindow and have no problem:
>>> QSettings Settings(Whatever...)
>>> Settings.setValue("pos", pos());
>>> Settings.setValue("size", size());
>>>
>>> and then load like
>>> QPoint Point = Settings->value("pos").toPoint();
>>> if (Point.x() < 1 || Point.y() < 1) {
>>>     Point.setX(DEFAULT_GUI_POS_X);
>>>     Point.setY(DEFAULT_GUI_POS_Y);
>>> }
>>>
>>> QSize Size = Settings->value("size").toSize();
>>> if (Size.height() < 1 || Size.width() < 1) {
>>>     Size.setHeight(DEFAULT_GUI_SIZE_X);
>>>     Size.setWidth(DEFAULT_GUI_SIZE_Y);
>>> }
>>>
>>> move(Point);
>>> resize(Size);
>>
>>
>> I've tried it like that, also by calling geometry()/setGeometry(), 
>> saveGeometry()/restoreGeometry(). All cause the windows to shift up/left.
>>
>> The only solution I could come up with is to also save the 
>> frameGeometry (which seems to be shifted up/left too much), and then 
>> add on the difference between the geometry and the frameGeometry.
>>
>> As I mentioned, I believe this is a WINDOWS ONLY problem.
>>
>> But storing the geometry and then restoring it definitely causes 
>> problems.
>>
>>>
>>> Sandor
>>>
>>>
>>> -----Original Message-----
>>> From: Paul Miller [mailto:paul@xxxxxxxxxx]
>>> Sent: 05/04/2007 16:17
>>> To: QT Interest List
>>> Subject: Qt 4.2 (Windows) - workaround for window geometry shift?
>>> (windowcreeps upward)
>>>
>>>
>>> I see that if you do what the docs suggest to save/restore the window 
>>> geometry, on Windows, each time you restore the geometry, the window 
>>> shifts up by the titlebar height, and left by the frame width.
>>>
>>> Looks like the saved window geometry includes the window frame, but 
>>> restoring the geometry does NOT take into account the frame.
>>>
>>> I'll report a bug, but is there a workaround for this?
>>>
>>
>>
> 
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 
> 


-- 
 [ signature omitted ] 

Message 5 in thread

Paul Miller wrote:
> 
> I've tried it like that, also by calling geometry()/setGeometry(), 
> saveGeometry()/restoreGeometry(). All cause the windows to shift up/left.
> 
> The only solution I could come up with is to also save the frameGeometry 
> (which seems to be shifted up/left too much), and then add on the 
> difference between the geometry and the frameGeometry.
> 

Hi Paul, I was having the same problem with geometry()/setGeometry().
The problem went away with saveGeometry()/restoreGeometry(). Your
problem may be the timing of the save settings. Something may be
happening prior to the actual save.

Mark




--
 [ signature omitted ]