PDA

View Full Version : Resize Widget To Desktop Size



fruzzo
23rd September 2008, 10:51
Hi,
I've a question for you...Is there a simple way to resize my widget to desktop size?
I try this code but it seem don't work fine:

int width = QApplication:desktop()->width();
int height = QApplication:desktop()->height();
mainWindow->resize(width, height);

Infact if I try to get the window height:

int mwHeight = mainWindow->height();
then mwHeight is less of QApplication:desktop()->height() (about 20 pixel)

Any idea?

And how I can call directly the maximixe button of the title bar to do the same resize by code?

spirit
23rd September 2008, 11:00
look at this property
http://doc.trolltech.com/4.4/qwidget.html#maximized-prop

fruzzo
23rd September 2008, 15:05
Ok I've solved the problem using the showMaximized method.
It work fine only if insert before a resize:

mainWindow->resize(100,100);
mainWindow->showMaximized();
Why?

jpn
23rd September 2008, 15:11
For me it works with Qt 4 without any additional tricks:


#include <QtGui>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QWidget window;
window.showMaximized();
return app.exec();
}

fruzzo
23rd September 2008, 16:42
For me it works with Qt 4 without any additional tricks:


#include <QtGui>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QWidget window;
window.showMaximized();
return app.exec();
}


I know...I try some examples like your code and they works fine.
However I'm working with Qt3.3.5 and window is a QMainWindow not a QWidget.
I want remove the resize because I've some problmes with it...so any idea how to resolve the question?

jpn
23rd September 2008, 16:57
I know...I try some examples like your code and they works fine.
In that case it is highly probable that the bug is on your side. It's just hidden somewhere in a big and complex project. That's why it's always a good idea to put up together a minimal compilable test application reproducing the problem.


However I'm working with Qt3.3.5 and window is a QMainWindow not a QWidget.
Actually, QMainWindow IS A QWidget. And QWidget::showFullScreen() functionality is implemented in QWidget code. I doubt you can reproduce the problem with a plain QMainWindow either. If you can reproduce it with a QMainWindow subclass, then the problem might be in that subclass.

fruzzo
2nd October 2008, 15:29
How can I catch the signal emitted when launch mw->showMaximized()? And a way to know when resize (after showMaximized()) is completed?