[Interest] Displaying the same QWebView twice in my app

Jirka Daněk j at dnk.cz
Wed Dec 5 10:57:04 CET 2012


Dear fellow subscribers!

I want to display the same QWebView in two different windows. I
tried/considered these three different solutions but could not make any to
work.

1\ Subclass QWebView, override paintEvent() and redirected() methods. The
overriden redirected() will redirect drawing of the widget into a QPixmap
and paintEvent will call the super function and then update the QLabels
that display the drawn pixmap. This works. It has the disadvantage that it
also brings up a black window of what used to be the WebView. So I need a
way to hide that window but keep the WebView behaving like it is actually
displayed.

2\ Call grab() on the WebView. I haven't figured out when to call it. I
want to grab every time something on the page in WebView changes. I tried
overriding paintEvent, tried to keep a flag whether it is doing a normal
redraw or grab but I always ended up either crashing the app or with an
infinite loop of draws. My best bet here is to just call grab() 30 times
per second on the WebView from outside and hope it will be enough. i think
it will.

In both cases I'll have to somehow sort out resending events from the
QLabels to the WebView. But I expect an EventFilter can be made to work for
that.

3\ have two WebViews and synchronize the page inside using some HTML5
trickery in JavaScript. (as I am creating the HTML page so I have control
over it). I know how to do this and I know it would work, but I do not like
it and would prefer something in the lines of 1\ or 2\.

I would much welcome any comments on it and possibly suggestions on in 1\
how to keep the cannibalised QWebView from showing on screen; in \2 how to
avoid having to do a periodic grab() maybe some advice on the event
resending business or possibly how to achieve my ultimate goal described
bellow with some other means.

Ultimate goal:
I have a slide deck in HTML. I am playing with the idea to show it from my
QT app instead of my regular browser to have more control over it and solve
the following issue. The room i am presenting in has two projectors. In my
presentation, I am showing slides or videos, switching between the two
often.
- When I am showing slides, I have the slide appear on both screens (so
left and right half of the autience has it in front of their eyes).
- When I am showing video, I am stretching it over both adjacent screens to
give it a wall effect.

That means that I am often switching between two setups -- web browser with
slides + cloning my screen and Vlc with video + wall setting in vlc + two
independent screens. This switching takes time and makes my presentation
less smooth.

Therefore, I want to have both "modes" of my presentation served from one
app with the same screen settings. The slide synchronization would be
possible to do in HTML5, but the video wall is not:
In the future I would like to implement playing videos in the way that the
left half of the video will be playing on the left screen and the right one
on the right screen / fullscreen windows. The screens are adjacent to each
other so I'll get a wall effect. That is something that is very likely
undoable with just HTML5 in the browser (I tried and failed to either keep
the left and right half in sync or to sustain good framerate)

Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121205/2a5db442/attachment.html>


More information about the Interest mailing list