PDA

View Full Version : QDockWidget showFullScreen() only works on Windows



xam
15th April 2013, 22:02
Hello,

i figured out that the showFullScreen() method of an undocked (floated) QDockWidget behaves unhandy/different under Windows XP compared to OSX and Linux. Only under XP it behaves as i aspected - appears maximized without title bar. OSX (lion) just maximizes it and ubuntu gnome seems to do just nothing.

So how can i achieve a real fullscreen mode for a floated QDockWidget under Linux aswell as under OSX and Windows?

I additionally created an stack overflow question with this concern: stckoerflw (http://stackoverflow.com/questions/15976134/qdockwidget-showfullscreen-not-working-on-ubuntu-gnome), here you can see a simple example how to reproduce this different (in my p.o.v. wrong) behaviour of qt4.8. Please have a look, there you'll find some additional informations.

Any suggestions are wellcome - shure the OS'es have different window managing systems - but that's why i think this may be a bug or unwanted behaviour within qt!?

I am very interested in a linux (ubuntu gnome shell) solution, because this the major plattform my app is running on.
Nevertheless a plattform independant solution is the reason why i choose qt for gui develepment...

Thanks a lot

wysota
16th April 2013, 20:22
Move the widget content out of the dock widget and then make it full screen.

xam
23rd April 2013, 01:04
What exactly do you mean by:
Move the widget content out of the dock widget and then make it full screen I'm unsure how to do this. Maybe you could be more precise or provide a simple example how to move the content of a floated dockwidget out of it and make it full screen (and vice versa).

Nevertheless i found a quick work around using style sheets. Actually it's all right for my purpose but it's not really a solution to the problem:



// Set full screen:
dockflags = dw->windowFlags();
styleSheet = dw->styleSheet();
geometry = dw->geometry();

dw->setWindowFlags( Qt::Window );

dw->setStyleSheet(
QString("QDockWidget{ border: 0px; color: #000099; background-color: black; margin: 0px; padding: 0px }") +
QString("QDockWidget::title{ text-align: center; background-color: black; padding: 0px; margin: 0px; }") +
QString("QDockWidget::close-button, QDockWidget::float-button { border: 0px solid black; background: black; padding: 0px; }") +
QString("QDockWidget::close-button:hover, QDockWidget::float-button:hover { background: gray; }") +
QString("QDockWidget::close-button:pressed, QDockWidget::float-button:pressed { padding: 1px -1px -1px 1px; }") );

dw->showFullScreen();
...
// Reset from fullscreen:
dw->setWindowFlags( dockflags );
dw->setStyleSheet( styleSheet );
dw->setGeometry(geometry);

dw->show();

The title bar of the dock widget is still there but it's simply "hidden"; colored black.

Finally this is not the full screen behaviour i'm happy with, but it kinda works for now. (I'm displaying video and/or 3D models within the window). Furthermore i'm still searching for a better/real solution wich is not a hack like this. Maybe i have to think about not using QDockWidgets at all, due to the lack of identic behaviour at different OSs (especially in that case of the showFullScreen method). Actually i am just a little "satisfied" - so i'm still searching for a more convenient solution. Any more hints are welcome, thnx so far...

wysota
23rd April 2013, 07:29
I mean reparent content of the widget to null so that it becomes a top-level window and then make it full screen.

antweb
15th April 2015, 12:24
I am facing issues with the reparenting method.
I have a MainWIndow which has a horizontal layout with certain number of widgets in it in the form of a stackedwidget, of which only one is visible at a time.
I am checking for condition on mouseReleaseEvent.
This is the code I have used:


if (maxMode== false)
{
m_enOrigWindowFlags = this->windowFlags();
m_pSize = this->size();
this->setParent(0);
this->setWindowFlags( Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
this->showMaximized();
maxMode = true;
}
else
{
this->setParent(m_pParent);
this ->resize(m_pSize);
this->overrideWindowFlags(m_enOrigWindowFlags);
this->move(280,40);
this->show();
maxMode = false;
}


Normal mode:
11092

On clicking on the first camera:
11091

If i use fullscreen in case of maximized then my widget disappears on coming back. I want it to be fullscreen with a black background.
THe top part with buttons is the MainWindow. The 4 cameras are a widget inside the horizontal layout of the MainWindow.
Please help!