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:
#include <QtCore>
#include <QtGui>
#include "Test.h"
int main (int argc, char **argv)
{
w->move (0,0);
w->resize(2400, 600);
w->show();
Test lT(w);
QTimer::singleShot (2000,
&lT,
SLOT(setSize
()));
return app.exec();
}
#include <QtCore>
#include <QtGui>
#include "Test.h"
int main (int argc, char **argv)
{
QApplication app (argc, argv);
QMainWindow *w = new QMainWindow();
w->move (0,0);
w->resize(2400, 600);
w->show();
Test lT(w);
QTimer::singleShot (2000, &lT, SLOT(setSize()));
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Test.h:
#include <QtCore>
#include <QtGui>
{
Q_OBJECT
public:
{
mMW = aMW;
}
public slots:
void setSize ()
{
mMW->resize (2400, 600);
}
private:
};
#include <QtCore>
#include <QtGui>
class Test : public QObject
{
Q_OBJECT
public:
Test (QMainWindow *aMW)
{
mMW = aMW;
}
public slots:
void setSize ()
{
mMW->resize (2400, 600);
}
private:
QMainWindow *mMW;
};
To copy to clipboard, switch view to plain text mode
Bookmarks