[Qt-interest] setUnifiedTitleAndToolBarOnMac and Cocoa Qt cause problems

Israel Brewster israel at frontierflying.com
Wed Jul 22 22:05:30 CEST 2009


Ok found a work-around of sorts: it appears that this error only  
happens if the window is sized and positioned before show() is called.  
This is actually mentioned in the docs in reference to X11 windows: (http://doc.trolltech.com/4.5/geometry.html 
) where it says:
> "...A workaround is to call setGeometry() after show()..."

HOWEVER, it goes on to say:
> "...A safer solution is to store both pos() and size() and to  
> restore the geometry using QWidget::resize() and move() BEFORE  
> calling show()...This method works on Windows, MAC OS X, and most  
> X11 window managers" [emphasis added].

As my test cases show, however, this doesn't work under the specified  
conditions (Cocoa and setUnifiedTitleAndToolBarOnMac). Under these  
conditions, from what I have been able to tell, the ONLY way to  
successfully restore the size of the window to to call either  
setGeometry or resize() and move() AFTER calling show(). This,  
unfortunately, has all the disadvantages listed in the above  
referenced documentation. saveGeometry() and restoreGeometry() appear  
to fail regardless of when called (before or after show()).

As a somewhat interesting side note, the degree of failure does vary  
depending on which method is used. For example, with a window that  
initially has a height of 454, when restored using setGeometry() it  
has a height of 433 - a decrease of 21. However, when that same 454  
window is restored using resize(), it ends up with a height of 412 -  
an additional decrease of 21 over the change with  setGeometry, or 42  
total. Not sure why 21 is the magic number here, or why resize() makes  
the window smaller than setGeometry().

-----------------------------------------------
Israel Brewster
Computer Support Technician II
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Israel Brewster.vcf
Type: text/directory
Size: 397 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090722/98110a8d/attachment.bin 
-------------- next part --------------


On Jul 14, 2009, at 1:37 PM, Israel Brewster wrote:

> Using the setUnifiedTitleAndToolBarOnMac option with a cocoa build  
> of Qt appears to cause issues when attempting to save/restore window  
> positions. With this combination, when attempting to restore the  
> size and position of a window, the window invariably (at least on my  
> machine) appears shifted and/or resized. This is the case when using  
> any of the standard resize options, such as setGeometry(),  
> restoreGeometry() or resize() and move(). Using a carbon build all  
> methods work properly, as does the Cocoa build when not using the  
> unified title and toolbar option. Is the  
> setUnifiedTitleAndToolBarOnMac option deprecated with the cocoa  
> build? Or is this a bug? I have attached a QTest test case  
> demonstrating these issues.
>
> -----------------------------------------------
> Israel Brewster
> Computer Support Technician II
> Frontier Flying Service Inc.
> 5245 Airport Industrial Rd
> Fairbanks, AK 99709
> (907) 450-7250 x293
> -----------------------------------------------
> <Israel Brewster.vcf>
> < 
> testWindow 
> .cpp 
> > 
> < 
> testWindow 
> .h><testWindow.pro>_______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest



More information about the Qt-interest-old mailing list