title: Restoring window position
body: <p>I am developing QT application and I have a problem with restoring window from trayicon.</p>
  
  <p>Here is a code connected with tray icon :</p>
  
  <pre><code>createActions();
  createTrayIcon();
  setIcon();
  
  trayIcon-&gt;show();
  
  connect(
          trayIcon,
          SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
          this,
          SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason))
         );
  </code></pre>
  
  <p>create actions </p>
  
  <pre><code>   open = new QAction(tr("&amp;Open"), this);
     connect(open, SIGNAL(triggered()), this, SLOT(show()));
  
     close = new QAction(tr("&amp;Quit"), this);
     connect(close, SIGNAL(triggered()),qApp, SLOT(quit()));
  
   void MainWindow::createTrayIcon()
  {
  trayIconMenu = new QMenu(this);
  
  trayIconMenu-&gt;addAction(open);
  trayIconMenu-&gt;addSeparator();
  trayIconMenu-&gt;addAction(close);
  trayIcon = new QSystemTrayIcon(this);
  trayIcon-&gt;setContextMenu(trayIconMenu);
  
  
  }
  
  void MainWindow::trayIconClicked(QSystemTrayIcon::ActivationReason reason)
  {
      if(reason == QSystemTrayIcon::Trigger)
          this-&gt;show();
  }
  
  
  void MainWindow::closeEvent(QCloseEvent *event)
  {
  
  
       QString title = "Smart Typer 2000";
       QString text = "Aplikácia stále beží, obnovíte ju poklepením po ikonke, zrušíte ju stlačením ikonky pravým tlačítkom,"
                          "a následným zvolením možnosti Quit";
      if (trayIcon-&gt;isVisible()) {
  
          trayIcon-&gt;showMessage(title,text,QSystemTrayIcon::Information,5000);
          trayIcon-&gt;setToolTip("Smart Typer 2000");
          this-&gt;setVisible(false);
  
          event-&gt;ignore(); // Don't let the event propagate to the base class
      }
  </code></pre>
  
  <p>}</p>
  
  <p>So, when i click [x] button in mainwindow, application is send to trayicon, when i click on this trayicon, the mainwindow size and position is restored, which is good.</p>
  
  <p>But when i press [_] button, application is minimized, both task bar icon and system tray icon are visible, and after clicking on tray icon, the application main window wont restore itself. (also window wont restore itself even if i click on trayicon with right button and then select "Open" option)</p>
  
  <p>I tried various things like, instead of</p>
  
  <pre><code>this-&gt;show();
  </code></pre>
  
  <p>I tried call</p>
  
  <pre><code>this-&gt;showNormal();
  </code></pre>
  
  <p>the only time, when window was restored, was when I called</p>
  
  <pre><code>this-&gt;showMaximized();
  </code></pre>
  
  <p>of course, the main window was really maximized, which was not very nice, so I set max width and max height to the default  application dimensions (I didnt mind it, because  my application does not need to be any bigger), but...
  although window was restored, and the size was good, the position was not , window was restored in the upper left corner of my monitor, which kinda suck.
  So I tried use this piece of code
  <a href="http://doc.qt.io/archives/qt-4.7/restoring-geometry.html" rel="nofollow">http://doc.qt.io/archives/qt-4.7/restoring-geometry.html</a></p>
  
  <p>I saved windows state and geometry on hide and close events, then I tried to restore it when trayicon was clicked, but with no success..</p>
  
  <p>So, do you have any ideas ? How to restore window by clicking on trayicon when window was minimized ?</p>