1

I have an issue and I can't to solve it. It's look simple, but I can't find an answer.

I have created MainWidget which I call in main.cpp. It looks like

MainWidget mw;
mw.showMaximized();

And I see maximized widget. But when I'm trying to get size of mw, I get QSize(800, 600), which is obviously wrong. It looks like widget didn't change his size, just looks bigger (?) when I called showMaximized() method?

Is there any chance to get ACTUAL SIZE of widget? It will be different, depending on screen resolution, which I want to use to resize properly widgets inside MainWindow.

Is there any change to do that? Any help will be good.

Tatarinho
  • 754
  • 2
  • 11
  • 31
  • 1
    The geometry of any widget in Qt is invalid until the widget gets shown. Override `showEvent` and/or `resizeEvent` and get the geometry there. – peppe Jan 03 '15 at 22:56

1 Answers1

3

http://comments.gmane.org/gmane.comp.lib.qt.general/41275

QMainWindow::showMaximized() Doesn't Update Size

The questions seems to have been asked multiple times, and each one ends up with something like handle 'resizeEvent'. I don't think that there is a way around it really. Implementing a handler for resizeEvent doesn't seem too hard though. For a some reference:

http://qt-project.org/doc/qt-4.8/qresizeevent.html

Community
  • 1
  • 1