Results 1 to 7 of 7

Thread: Qt 4.7: problem with restoreGeometry / saveGeometry on Linux (Ubuntu)?

  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt 4.7: problem with restoreGeometry / saveGeometry on Linux (Ubuntu)?

    Hi,

    I was wondering someone had ever come across the case where saveGeometry and restoreGeometry work fine on Windows and Mac OS X, but has a strange (?) behaviour on Linux (Ubuntu 10.10 at least). Basically, I have some code that saves the geometry of my application:

    Qt Code:
    1. QSettings settings(SETTINGS_INSTITUTION, appName);
    2.  
    3. settings.setValue(SETTINGS_GENERAL_GEOMETRY, saveGeometry());
    To copy to clipboard, switch view to plain text mode 
    and, in the same way, I have some code to retrieve it:

    Qt Code:
    1. QSettings settings(SETTINGS_INSTITUTION, appName);
    2.  
    3. restoreGeometry(settings.value(SETTINGS_GENERAL_GEOMETRY).toByteArray());
    To copy to clipboard, switch view to plain text mode 
    Now, as I said above, everything works fine and as expected on Windows and Mac OS X, but for some unknown reason (to me, at least!), the Y position of the main window gets shifted every time I start my application. In fact, it gets shifted down by 29 pixels until it reaches the bottom of my screen, at which point it stays there.

    I traced the Y position of my main window (using pos().y()) and was surprised to find out that it returned 53 while it should have been 24 (because of the Ubuntu bar at the top). So, yes, 53-24 gives us our (infamous) 29 pixels. I tried to autohide the Ubuntu bar at the top, just to see whether it would make a difference, but to no avail.

    So... has anyone ever across that problem? If so, is there something that can be done about it?

    Cheers, Alan.

  2. #2
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt 4.7: problem with restoreGeometry / saveGeometry on Linux (Ubuntu)?

    So, as anyone ever come across the above? Surely, I must not be the only one facing that problem, and who wants and needs a solution for it?...

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt 4.7: problem with restoreGeometry / saveGeometry on Linux (Ubuntu)?

    My guess would be it is caused by a non-compliant implementation of the window manager (are you using Metacity or Compiz?) which doesn't include the window decoration in some geometry calculation or something like this. Try switching to a different window manager and see if the problem persists.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt 4.7: problem with restoreGeometry / saveGeometry on Linux (Ubuntu)?

    Very good point about the window manager! I am indeed using Compiz and having now disabled it, it all works fine. Argh, I hate implementations that are not compliant! In any case, thanks a lot for the hint, there is clearly nothing I can do about it (or is there?).

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt 4.7: problem with restoreGeometry / saveGeometry on Linux (Ubuntu)?

    Quote Originally Posted by agarny View Post
    In any case, thanks a lot for the hint, there is clearly nothing I can do about it (or is there?).
    Well... you can abandon compiz, that's for sure You can also modify either Compiz or Qt to be compatible with each other, they are both open-source. Or you can ask someone to do it for you, of course.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt 4.7: problem with restoreGeometry / saveGeometry on Linux (Ubuntu)?

    Well, I think I am just going to make a note of it in my application's documentation and that's it.

  7. #7
    Join Date
    Jun 2011
    Posts
    4
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: Qt 4.7: problem with restoreGeometry / saveGeometry on Linux (Ubuntu)?

    Try to save/restore the window state with saveState() and restoreState() too. In combination this works on ubuntu to get the correct geometry.

Similar Threads

  1. Can't Compile on Ubuntu Linux
    By mpauley in forum Newbie
    Replies: 6
    Last Post: 9th April 2010, 22:00
  2. Replies: 3
    Last Post: 18th February 2010, 16:43
  3. Replies: 0
    Last Post: 4th November 2009, 07:45
  4. Replies: 5
    Last Post: 6th March 2009, 09:58
  5. saveGeometry in X11
    By arjunasd in forum Qt Programming
    Replies: 16
    Last Post: 7th August 2007, 23:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.