[OpendTect_Developers] Qt's widget embedding
Bruno Chaintreuil
bruno.chaintreuil at dgbes.com
Tue Aug 31 10:07:39 CEST 2010
Dear All,
The new Qt libraries support the embedding of objects in a scene, thus
giving the possibility to draw complex user interface structures that
can be dynamically reorganized after their creation. An example of the
nice possibilities given by this feature is the Well to seismic
correlation panel (see attached pictures) in which well displays are
juxtaposed with seismic viewers on a common scene. Well displays can be
moved and resized after drawing on user's convenience. They can also be
put aside or on top of the seismic with transparent background. This
gives the user full flexibility and control over well data display.
Qt is a library that provides a range of tools to build 2D graphical
elements. The main object is the graphics scene for managing the
graphics items. All can be visualized in a graphics view. In OpendTect
we do not use directly the Qt items to build our graphical user
interface but have an intermediate layer that consists of more
elaborated objects. Each object contains at least a Qt element and
additional functions ( for instance, a uiObject is a class based on a
QWidget, a uiGraphicsScene is based on a QGraphicsScene, and so on.. ).
Qt versions 4.5 and further enable the embedding of QWidgets into a
QGraphicsScene. This is translated in our OD ui-Framework by the
possibility to add uiObjects (or uiGroups) to the scene of a
uiGraphicsView. The objects are actually first embedded into specific
graphics items and then drawn on the scene. The resulting advantage is
the dynamic display of the uiObject just like every other graphics item.
This gives therefore the possibility to modify it after it has been drawn.
To support this new feature, a few classes have been implemented at
/uiBase and /uiTools levels in OD 4.1. A uiObjectItem class has been
added to the list of the graphics items ( /uiBase/uigraphicsitemimpl.h
). This new uiGraphicsItem holds the uiObject. It can be drawn by a new
specific scene, the uiGraphicsObjectScene ( /uiBase/uigraphicsscene.h ).
This scene contains in addition a horizontal layout which will nicely
position the items into a horizontal order regardless of their exact
position. On top of all this, a uiObjectItemView contains the
uiGraphicsScene and a few handy functions to handle the items (
/uiTools/uiobjectitemview.h ).
The work flow to implement the embedding of uiObject can be depicted as
follow:
- create a uiObjectItem by passing it a uiObject or a uiGroup. Make sure
the parent of the object is 0.
- add this uiObjectItem to a uiGraphicsScene, either by creating a new
one, or by using the one from the uiObjectItemView.
- you can add directly the item to the scene by giving a specific
position ( x, y ), or you can give it to the horizontal layout which
will take care of the position. In the last case you have to specify a
stretch factor to your item to know which space it will occupy in the
layout.
A few limitations have been encountered yet:
-Layered embedding is not supported, which means you can not embed a
uiObject into an already embedded one, although Qt announced a fix for
their coming release.
-So far only a horizontal layout has been implemented for the
uiGraphicsObjectScene. Feel free to add a vertical one if needed!
If you have any question on this topic, please do not hesitate to
contact me.
Best Regards,
Bruno Chaintreuil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: well_corr.png
Type: image/png
Size: 1944347 bytes
Desc: not available
URL: <http://lists.opendtect.org/pipermail/developers/attachments/20100831/66b00186/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: well_corr_on_top.png
Type: image/png
Size: 2280785 bytes
Desc: not available
URL: <http://lists.opendtect.org/pipermail/developers/attachments/20100831/66b00186/attachment-0001.png>
More information about the Developers
mailing list