Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found that a combination of all the previous answers here was necessary on Fedora 14. Be careful <strong>not</strong> to save the size and position when the window is maximized!</p> <pre><code>void MainWindow::writePositionSettings() { QSettings qsettings( "iforce2d", "killerapp" ); qsettings.beginGroup( "mainwindow" ); qsettings.setValue( "geometry", saveGeometry() ); qsettings.setValue( "savestate", saveState() ); qsettings.setValue( "maximized", isMaximized() ); if ( !isMaximized() ) { qsettings.setValue( "pos", pos() ); qsettings.setValue( "size", size() ); } qsettings.endGroup(); } void MainWindow::readPositionSettings() { QSettings qsettings( "iforce2d", "killerapp" ); qsettings.beginGroup( "mainwindow" ); restoreGeometry(qsettings.value( "geometry", saveGeometry() ).toByteArray()); restoreState(qsettings.value( "savestate", saveState() ).toByteArray()); move(qsettings.value( "pos", pos() ).toPoint()); resize(qsettings.value( "size", size() ).toSize()); if ( qsettings.value( "maximized", isMaximized() ).toBool() ) showMaximized(); qsettings.endGroup(); } </code></pre> <p>In main(), the position settings are read before showing the window the first time...</p> <pre><code>MainWindow mainWindow; mainWindow.readPositionSettings(); mainWindow.show(); </code></pre> <p>...and these event handlers update the settings as necessary. (This causes a writes to the settings file for every mouse movement during the move and resize which is not ideal.)</p> <pre><code>void MainWindow::moveEvent( QMoveEvent* ) { writePositionSettings(); } void MainWindow::resizeEvent( QResizeEvent* ) { writePositionSettings(); } void MainWindow::closeEvent( QCloseEvent* ) { writePositionSettings(); } </code></pre> <p>Still, the vertical component of the position is not quite right, it seems to be ignoring the height of the window title bar... if anyone knows how to deal with that let me know :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload