qt5 - What is the difference between a QWindow and QWidget -


the qt 5.0 provides new qwindow class. while documentation on class quite comprehensive, failing see how qwindow different qwidget class, , in cases prefer former. both provide handy way of visualising sorts of things screen, both can use qpainter drawing, , both have way interact opengl.

in api description, says that:

an application typically use qwidget or qquickview ui, , not qwindow directly.

so doesn't seem advantage window. moreover, states:

windows can potentially use lot of memory. usual measurement width times height times color depth. window might include multiple buffers support double , triple buffering, depth , stencil buffers.

which doesn't seem in favour of using qwindow. in cases use it?

qwindow has been introduced in qt 5.0 due gui / widgets split. qwidget lives in own library (qtwidgets); necessary provide abstraction of "toplevel window" non-widgets based applications, , qwindow created -- , lives in qtgui.

there entire class of non-widgets based applications: using qtquick2. don't use qtwidget library @ all, , matter of fact, when using them you're somehow using qwindows explicitely (qquickview inherits qwindow).

even when using widgets, top-level qwindows created qt kernel, keeps properties , flags of such qwindow objects in sync corresponding top-level qwidgets. way can deal widgets did, without knowing qwindow @ all. existing applications continue run expected, etc. etc.

the reason (so far) i've been using qwindows explicitely specific use case: to draw pure opengl content. easy achieve (by setting opengl surface type on window), , avoids bring in additional dependencies (qtwidgets, qtopengl, etc., have cost in terms of library size); it allows create opengl drawing surface in 10 lines of code which work on linux, windows, mac, qnx, "embedded linux", , android , ios too. point of view acts perfect sdl replacement. :)


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -