[Development] QWindow::setScreen() and QQuickWindow

Alan Alpert 416365416c at gmail.com
Sat Apr 12 02:16:55 CEST 2014


On Fri, Apr 11, 2014 at 12:56 PM, Rafael Roquetto
<rafael.roquetto at kdab.com> wrote:
> Hello,
>
> I have been investigating an interesting bug (using QNX as the platform for
> Qt). Here is a brief summary:
>
> (all code inside main() and before app.exec())
>
>     QQuickView v;
>     v.setScreen(someSecondScreen);
>     v.show(); // works as expected
>
> but
>
>     QQuickView v;
>     v.show();
>     v.setScreen(someSecondScreen); // window is never shown
>
> Is this the expected behavior?

Yes. setScreen expects to destroy the backing window and recreate it,
so it passes onto users the expectation that they will have to reset
all window properties afterwards.

I'm not sure what QQuickView should do, but in the declarative case
where you might have a "Window { visible: true; visibility:
Window.FullScreen }" it would be expected to reset all the properties
to what's in QML. I doubt it does that yet, and that's a bug ;) .

> The reason this happens is because
> QWindow::setScreen() calls destroy(), which triggers setVisible(false).
> Afterwards, it calls create() but create() never bothers to display the window
> again. In other words, it does
>
>     QWindow::setVisible(true) //coming from show();
>     QWindow::setVisible(false) //coming from setScreen() -> destroy()
>
> For some reason beyond my knowledge, QtWidgets do not suffer for this bug,
> i.e.:
>
>     QWidget w;
>     w.setScreen(secondScreen);
>     w.show(); // works!
>
> and
>     QWidget w;
>     w.show();
>     w.setScreen(secondScreen); // also works
>
> I digged a bit inside the QWidget code and it also follows the pattern of
> having setVisible(true) followed by setVisible(false) called, just like in the
> QQuickWindow case. However, something is happening that in spite of that the
> widget is being shown regardlessy.
>
> Any thoughts? Comments?

Last time I was playing around with multiwindow support (about a year
ago), QNX was the only platform where setScreen worked reliably. So
the strange stuff happening could be related to the platform
implementation, as we have no other platforms to compare it with. It
also makes it hard to determine the "correct" multi-screen API, when
there's no clear picture of how it would work on the majority of
platforms.

--
Alan Alpert



More information about the Development mailing list