How about just calling QWidget::showFullScreen()?
Then you don't call QWidget::showFullScreen().
There are many different "what ifs" we could discuss. If you have a frameless window, you can't even move it or close it so what's the point of having it this way?Wouldn't the flags method I suggested be a more general solution that would work regardless of window size?
Well, duh, I guess not
Granted, it's not appropriate behavior, but that doesn't answer the question. If for some insane reason I wanted to put a non-full screen, frameless window with no title bar in the user's face, how would I do it? Is the method I presented above the right way, or is there a better way?
(Not trying to hijack the thread, just trying to learn something relevant to the original topic).
d_stranz (26th October 2010)
Hi,
Thanks lykurg and wysota--but in fact neither solution worked! My code is simply this:
Qt Code:
MyMainWindow::MyMainWindow() { ui->setupUi(this); //It occurs to me now to try doing the flag settings before this, will try tomorrow ... Qt::WindowFlags flags( Qt::Window | Qt::FramelessWindowHint | Qt::CustumizeWindowHint); #ifdef Q_WS_X11 flags |= Qt::X11BypassWindowManagerHint; #endif setWindowFlags(flags); setGeometry(scr_x,scr_y,scr_width,scr_height); showFullScreen(); update(); }To copy to clipboard, switch view to plain text mode
Having the update() in or not doesn't make any difference as far as the bar is concerned.
As for why I want a window like this, it's for a simple calibration program for calibrating an eye tracker. The subject doesn't interact with the window at all, just looks at the points that appear on the screen. I could get a window like I want using the QGL classes, but I wanted something simple and lightweight (and I wanted to get some practice with the QPainter class).
Best,
Matt
The major difference between my test (using my own QMainWindow-derived class) and yours is that I pass the flags into the MainWindow constructor:
Qt Code:
Qt::WindowFlags flags( Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint ); MyMainWindow myMain( 0, flags ); myMain.show();To copy to clipboard, switch view to plain text mode
whereas you are setting the flags after your MainWindow is partly constructed. I notice you also aren't calling the constructor for QMainWindow in the initialization of your MainWindow constructor; I always do this:
Qt Code:
{ // whatever }To copy to clipboard, switch view to plain text mode
but perhaps you just omitted this bit from your example.
In my test, I also didn't display the main window as full screen, but I doubt this is crucial. The goal was to be able to remove the title bar, which my code does.
-- few minutes later --
I just inserted this at the end of my main window constructor:
Qt Code:
{ // whatever showFullScreen(); }To copy to clipboard, switch view to plain text mode
and I get a full-screen main window with no title bar.
So, it is possible that the window flags need to be set as arguments to the constructor, not as a method call from within it.
-- few more minutes later --
Sorry, I was wrong - it doesn't matter whether the flags are passed as a constructor argument or set via a method call in the constructor. Either way works.
Maybe you're just calling too many geometry-related methods. In my test, a simple sequence of
in the constructor works just fine, as does calling from .Qt Code:
setWindowFlags( Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint ); showFullScreen();To copy to clipboard, switch view to plain text mode
Last edited by d_stranz; 26th October 2010 at 04:26.
What's the point of passing all those flags and setting geometry of the window manually if you are then calling showFullScreen()?
Calling showFullScreen() and update() from a constructor is not a wise thing to do too. Your constructor should only contain the setupUi() call and then somewhere else in your code you should call showFullScreen().
Wow, this is frustrating, I responded to these comments several days ago but they didn't post, apparently. d_stranz--I actually did initialize QMainWindow in the MainWindow constructor, I just forgot to put that in the snippet. (My firewall at work blocks QtCentre ?!?! so I have to reply from home.) Passing window flags from the constructor didn't help. wysota--I had everything together in that snippet just to show that I had tried all those different things, I tried out showFullScreen(), manual settings independently as well.
I'll try to keep update() and showFullScreen() out of the constructor, and see if that helps. Thank you both, so far--
Matt
Bookmarks