neciu
neciu

Reputation: 4495

How to set QWidget fullscreen (but "real" fullscreen, change resolution, set modal to whole system)?

I'm trying to make a game using Qt, cause it is so awesome ;) and you have all the stuff you need for free. The only problem is in changing system resolution and setting QWidget (or QGLWidget) "real" fullscreen.

Have any one of you managed to do something like this? How was the portability of such approach? I'd like to deploy my app on all desktop systems.

Maybe use SDL or something like SMFL to make it fullscreen?

Pls, share your hacks!

Cheers.

Upvotes: 5

Views: 25288

Answers (3)

Exa
Exa

Reputation: 4110

This...

my_widget->setWindowState(Qt::WindowFullScreen);

... brings your widget to a full screen resolution. Isn't that what you need?

Edit: Alternatively you can call the slot showFullScreen.

Edit 2:

  1. WIN API
    1. EnumDisplaySettings
    2. ChangeDisplaySettings
    3. Detailed information
  2. X11
    1. I'm not familiar with this, you could ask a new question regarding how to change the screen resolution here
  3. Mac
    1. Same as X11

Upvotes: 11

gutek
gutek

Reputation: 1

Fullscreen:

topwidget->setWindowState(topwidget->windowState() ^ Qt::Window);

Upvotes: 0

Neox
Neox

Reputation: 2004

First you have to set corresponding window flags to make your widget modal, and also get rid of the window manager frame so it will be true fullscreen

widget->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);

and after that call widget->showFullScreen(); as Exa said.

Upvotes: 3

Related Questions