Hey board,

I've got a problem with the QMainWindow::resize() function on a dual monitor setup. See the attached files to reproduce (if you have dual monitor setup of course!). The problem exists at least with Qt 4.6.0 on X11/KDE, but if I recall correctly I've seen it with older versions of Qt as well.

Anyway, what basically seems to happen is that resize() cannot set a size larger than one screen before the window is drawn. In the example if call resize(2400, 600) before calling app->exec(), the window will then be shown with a size of 1600x600 (because my monitor has 1600 pixels horizontally).

Then, I do a QTimer::singleShot of two seconds, and after these two seconds I call resize(2400,600) again. Now, the window has the desired size.

Does anyone have a suggestion on a proper fix for this problem? Thanks!


PS I had some problems with the attachments, so here are the sources (its not much anyway)

main.cpp:
Qt Code:
  1. #include <QtCore>
  2. #include <QtGui>
  3.  
  4. #include "Test.h"
  5.  
  6. int main (int argc, char **argv)
  7. {
  8. QApplication app (argc, argv);
  9.  
  10. w->move (0,0);
  11. w->resize(2400, 600);
  12. w->show();
  13.  
  14. Test lT(w);
  15. QTimer::singleShot (2000, &lT, SLOT(setSize()));
  16.  
  17. return app.exec();
  18. }
To copy to clipboard, switch view to plain text mode 

Test.h:
Qt Code:
  1. #include <QtCore>
  2. #include <QtGui>
  3.  
  4. class Test : public QObject
  5. {
  6. Q_OBJECT
  7.  
  8. public:
  9. Test (QMainWindow *aMW)
  10. {
  11. mMW = aMW;
  12. }
  13.  
  14. public slots:
  15. void setSize ()
  16. {
  17. mMW->resize (2400, 600);
  18. }
  19.  
  20. private:
  21. };
To copy to clipboard, switch view to plain text mode