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::WindowFlags flags( Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint );
MyMainWindow myMain( 0, flags );
myMain.show();
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:
MyMainWindow
::MyMainWindow( QWidget * parent, Qt
::WindowFlags flags
){
// whatever
}
MyMainWindow::MyMainWindow( QWidget * parent, Qt::WindowFlags flags )
: QMainWindow( parent, flags )
{
// 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:
MyMainWindow
::MyMainWindow( QWidget * parent, Qt
::WindowFlags flags
){
// whatever
showFullScreen();
}
MyMainWindow::MyMainWindow( QWidget * parent, Qt::WindowFlags flags )
: QMainWindow( parent, flags )
{
// 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
setWindowFlags( Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint );
showFullScreen();
setWindowFlags( Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint );
showFullScreen();
To copy to clipboard, switch view to plain text mode
in the constructor works just fine, as does calling
myMain.showFullScreen();
myMain.showFullScreen();
To copy to clipboard, switch view to plain text mode
from
main()
main()
To copy to clipboard, switch view to plain text mode
.
Bookmarks