I seem have come across a problem that exists only in GNOME. The position of a dialog (obtained using pos() ) is incorrect, if and only if the dialog hasn't been moved from its starting position.

I have a included a small test program (Qt4) demonstrating this. At exit, it saves the position of the dialog to a text file ("test.txt"), which it reads upon starting again.

With KDE and XFce (the only other window managers I have), the dialog is placed in the correct position i.e. the position at last exit. But with GNOME, the dialog is placed in the correct position only if it was moved by the user from where it was created, otherwise it is placed at the top left hand corner of the screen.

I have search Qt forums and the Trolltech Task Tracker without finding any reference to this. Has anyone heard of such a possible bug before?

Qt Code:
  1. #include <QtGui>
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5. QApplication app(argc, argv);
  6. QDialog *dialog = new QDialog;
  7. QHBoxLayout *layout = new QHBoxLayout(dialog);
  8. QLabel *label = new QLabel("Testing widget->pos()", dialog);
  9. layout->addWidget(label);
  10.  
  11. // get position
  12. QFile file("test.txt");
  13. if (file.open(QIODevice::ReadOnly))
  14. {
  15. QString str = file.readAll();
  16. dialog->move(str.split(":")[0].toInt(), str.split(":")[1].toInt());
  17. file.close();
  18. }
  19.  
  20. dialog->show();
  21.  
  22. app.exec();
  23.  
  24. // write position
  25. if (file.open(QIODevice::WriteOnly))
  26. {
  27. QString str = QString("%1:%2").arg(dialog->pos().x())
  28. .arg(dialog->pos().y());
  29. file.write(str.toLocal8Bit());
  30. file.close();
  31. }
  32.  
  33. return 0;
  34. }
To copy to clipboard, switch view to plain text mode