Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 349
neciu Avatar asked Feb 23 '12 12:02

neciu


2 Answers

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
like image 71
Exa Avatar answered Oct 16 '22 05:10

Exa


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.

like image 28
Neox Avatar answered Oct 16 '22 06:10

Neox