PDA

View Full Version : Problem with showMaximized()



Lykurg
8th July 2007, 17:07
Hi,

in my QMainWindow-class I call showMaximized(), which works if I comment out following line:
img->setPixmap ( QPixmap(":/sokrates_600") );

img is a Label in an QWidget-based class, which builds a page in a QStackedWidget, which is set to central widget in the mainclass. When the image from the resource is set, the windows reduced to the preferred size of the image-holding-widget.

What's wrong with setPixmap, that it destroys my showMaximized()?


Thanks,
Lykurg

Note: If the application appears it seems that it starts in full screen, but then immediately shirks.

jpn
8th July 2007, 17:13
Have you changed default size policies?

Lykurg
8th July 2007, 17:31
Have you changed default size policies?

No, nothing. I use the Designer and just drag and drop a label to the widget.
I figured out, that if I don't apply a layout to the widget, the window is shown maximized. If I chose any layout, the window is shrinking.

Lykurg

Edit: Also if I code by hand same result:

window_startscreen::window_startscreen ( QWidget *parent )
: QWidget ( parent )
{
QLabel * img = new QLabel;
img->setPixmap ( QPixmap ( ":/sokrates_600" ) );

QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget ( img );
setLayout ( layout );
}

jpn
9th July 2007, 06:45
Which exact version of Qt on which platform? I can't reproduce the problem. I tried with following minimalistic code but the window is shown maximized. Does this not work for you?


#include <QtGui>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QWidget window;

QLabel* label = new QLabel;
label->setPixmap(QPixmap("test.png"));

QHBoxLayout* layout = new QHBoxLayout;
layout->addWidget(label);
window.setLayout(layout);

window.showMaximized();
return app.exec();
}

Lykurg
9th July 2007, 08:04
Well, your example works. I have attached a half-minimalistic example, which works but also don't:

Run make and start lykurg -> the window is small
edit mainwindow.ui in designer and remove the whole "datei"-menu
rebuild the project and start -> window is shown maximized???


I use Qt 4.3.0. What's the Problem with the menubar?


Thanks, Lykurg

Lykurg
9th July 2007, 17:27
... and I use the linux-version.

jpn
11th July 2007, 09:06
Just to mention, I was able to reproduce the problem on X11. However, I'm not exactly sure which part of generated code causes the faulty behavior.