Results 1 to 5 of 5

Thread: QSettings and Windows 7 64bit

  1. #1
    Join Date
    Dec 2006
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry QSettings and Windows 7 64bit

    The below code works just fine under Windows XP but fails to resize and move window under Windows 7 64bit.
    I can not understand why. This is a dual monitor system. HELP!

    void MainWindow::GetWindowSettings()
    {
    QSettings settings("C:/temp/temp.ini", QSettings::IniFormat);
    settings.beginGroup("MainWindow");
    resize(settings.value("size", QSize(800, 600)).toSize());
    move(settings.value("pos", QPoint(5, 30)).toPoint());
    settings.endGroup();
    }

    void MainWindow::SaveWindowSettings()
    {
    QSettings settings("C:/temp/temp.ini", QSettings::IniFormat);
    settings.beginGroup("MainWindow");
    settings.setValue("size", size());
    settings.setValue("pos", pos());
    settings.endGroup();
    settings.sync();
    }

    The settings are saved and read back in as I have tested that. However, the move and resize do not happed!!

  2. #2
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSettings and Windows 7 64bit

    I would use
    Qt Code:
    1. QSettings settings(qApp->applicationDirPath() + "/setting.ini",QSettings::IniFormat);
    2. settings.setValue("Main/Geometry", saveGeometry());
    To copy to clipboard, switch view to plain text mode 

    and
    Qt Code:
    1. QSettings settings(qApp->applicationDirPath() + "/setting.ini",QSettings::IniFormat);
    2. restoreGeometry(settings.value("Main/Geometry").toByteArray());
    To copy to clipboard, switch view to plain text mode 

    It works for me,in windows7,but 32bit
    It's not the goodbye that hurts,but the flashback that follow.

  3. #3
    Join Date
    Dec 2006
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSettings and Windows 7 64bit

    I really appreciate the response.
    First let me say it had nothing to do with Windows 7 64bit!

    This is what caused the problem:

    -----In main.cpp-----------------------------------------------------------------------------
    int main(int argc, char ** argv)
    {
    .
    .
    win.setGeometery(0, 0, 800, 600);
    win.show();
    .
    .
    }
    -----In MainWindow.cpp-----------------------------------------------------------------------------
    MainWindow::MainWindow( QWidget * parent, Qt::WFlags f) : QMainWindow(parent, f)
    {
    .
    .
    GetWindowsSettings();
    setupUi(this);
    .
    .
    }

    Making the call to win.setGeometery() was the issue.
    Not sure why but it is one of those things that really
    doesn't matter at the moment.

    Anyone have any thoughts on this?

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QSettings and Windows 7 64bit

    If you copy/pasted the code, you have a typo: win.setGeometEry(...)
    And if your code has correct name, check/debug the code, because i tested win.setGeometry(..) and it works on 7 64bit.

  5. #5
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSettings and Windows 7 64bit

    I think I might know what's going wrong.
    So you construct an object of MainWindow,in the constructor,you call GetWindowsSettings() to set its geometry thing.
    After the construction you also call
    Qt Code:
    1. win.setGeometery(0, 0, 800, 600);
    To copy to clipboard, switch view to plain text mode 
    so,setGeometery() overrides GetWindowsSettings() which makes GetWindowsSettings() useless.

    Perhaps you want to make sure it's 800*600 when the app first run.
    Qt Code:
    1. void MainWindow::GetWindowSettings()
    2. {
    3. QSettings settings("C:/temp/temp.ini", QSettings::IniFormat);
    4. settings.beginGroup("MainWindow");
    5. resize(settings.value("size", QSize(800, 600)).toSize());
    6. move(settings.value("pos", QPoint(5, 30)).toPoint());
    7. settings.endGroup();
    8. }
    To copy to clipboard, switch view to plain text mode 
    In GetWindowSettings(),you have already provided a default value.If the app cannot find the temp.ini.It will resize to 800*600.So,actually you don't have to call setGeometery().
    It's not the goodbye that hurts,but the flashback that follow.

Similar Threads

  1. Build 64bit Qt on 32bit XP
    By photo_tom in forum Installation and Deployment
    Replies: 2
    Last Post: 2nd March 2011, 09:28
  2. Deploying 64bit on 32bit OS
    By M. in forum Newbie
    Replies: 7
    Last Post: 23rd April 2010, 22:15
  3. Compiling Qt 32bit on 64bit os..
    By tgreaves in forum Newbie
    Replies: 2
    Last Post: 12th March 2009, 13:34
  4. Qt Eclipse Intergration Ubuntu 64bit
    By baddad in forum Qt-based Software
    Replies: 1
    Last Post: 16th February 2009, 05:18
  5. Replies: 1
    Last Post: 19th September 2008, 15:43

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.