
.. _qt-page:

########################
|ProductName| with Qt 
########################

.. image:: ../../images/qt.png
    :height: 150
    :align: right

Qt (https://qt.io or https://qt-project.org) is the primary toolkit used at HOOPS Envision for creating applications. 
HOOPS Envision Analyzer and HOOPS Envision VTFx Viewer uses Qt. 
This page describes how to integrate |ProductName| with Qt and how to get your application up and running with Qt. 
The description applies to Qt4, Qt5 and Qt6.

*****************
Creating a Viewer
*****************

All HOOPS Envision apps need one (or more) viewers in order to visualize the 3D data. We have example implementations 
that you can find in the **PlatformIntegration/Qt** folder of the distribution. We provide both QGLWidget and 
QOpenGLWidget based viewers. The legacy QtOpenGL module (classes prefixed with QGL) provides QGLWidget. QOpenGLWidget is 
intended to be a modern replacement for it. Therefore, especially in new applications, the general recommendation is to 
use QOpenGLWidget. All examples also derive from :class:`cee::vis::ViewerUIFramework`.

**ViewerGLWidget/ViewerOpenGLWidget:** ceeqtViewer(Open)GLWidget.h/.cpp |br|
This is a bare bone example with the minimum requirements for showing HOOPS Envision in Qt. There is no support for 
navigation/picking etc., just the minimum. To create your own Viewer, you should derive from this class.

**ViewerGLWidgetDemo/ViewerOpenGLWidgetDemo:** ceeqtViewer(Open)GLWidgetDemo.h/.cpp |br|
This is a demo application oriented implementation which adds Envision style navigation in addition to what is in 
ViewerGLWidget. This is the one used in the QtMinimal and QtMultiView examples which you can find in the 
**Examples/Qt folder** of the distribution.
This is a good starting point for adding |ProductName| to your app. The class derives from ViewerGLWidget and might 
be a good starting point for a Viewer in your application. We recommend copying the source code of this Viewer and 
modifying it to suit your needs in your application.

Please make sure that the :class:`cee::vis::OpenGLContextGroup` instance outlives the life of any viewers, i.e. all 
viewers must be deleted before the context group is deleted.

**Utilities**

The **PlatformIntegration/Qt** folder also contains some support classes to help developers in integrating Qt with 
|ProductName|.

The static classes in ceeqtUtilsCore.h and ceeqtUtilsGui.h contain methods for converting Qt types to and from cee types 
(e.g. QString <-> cee::Str).
There are also conversion functions to translate from Qt mouse events to :class:`cee::vis::MouseEvent`, 
:class:`cee::vis::MouseButton` and :class:`cee::vis::WheelEvent`.

****************
Example Programs
****************

To compile and run the example programs, use the .pro file in the example folder. If you are using Qt Creator you can 
just open this file. If you are using Visual Studio, you need to generate a .vcxproj file using qmake:

::

    qmake -tp vc

On Linux, just do:

::

    qmake 
    make

**QtMinimal**

.. |img_min| image:: ../../images/example_qt_minimal.png
   :width: 150

+-----------------------+------------------------------------------------------------------------------------+
| |img_min|             | **Location**\ : Examples/Qt/QtMinimal |br|                                         |
|                       | A very small example showing the basic requirements for a Qt application.          |
+-----------------------+------------------------------------------------------------------------------------+

**QtMultiView**

.. |img_multi| image:: ../../images/example_qt_multiview.png
   :width: 150

+-----------------------+------------------------------------------------------------------------------------+
| |img_multi|           | **Location**\ : Examples/Qt/QtMultiView |br|                                       |
|                       | A small example showing how to do multiple views/windows with |br|                 |
|                       | HOOPS Envision in Qt.                                                              |
+-----------------------+------------------------------------------------------------------------------------+


**QtSendToCloud**

.. |img_cloud| image:: ../../images/cloud_viewer.png
   :width: 150

+-----------------------+------------------------------------------------------------------------------------+
| |img_cloud|           | **Location**\ : Examples/Qt/QtSendToCloud |br|                                     |
|                       | An example showing how to send a VTFx file to Ceetron Cloud (using Qt).            |
+-----------------------+------------------------------------------------------------------------------------+


**QtReport**

.. |img_report| image:: ../../images/rep_qtreport.png
   :width: 150

+-----------------------+------------------------------------------------------------------------------------+
| |img_report|          | **Location**\ : Examples/Qt/QtReport |br|                                          |
|                       | An example showing how to create simple reports from the current model.            |
+-----------------------+------------------------------------------------------------------------------------+


**QtRepositoryManager**

.. |img_repman| image:: ../../images/rep_manager_example.png
   :width: 150

+-----------------------+------------------------------------------------------------------------------------+
| |img_repman|          | **Location**\ : Examples/Qt/QtRepositoryManager |br|                               |
|                       | An example which is a simple manager for a repository file. This allows you |br|   |
|                       | to open a repository file and view the actual snapshot content.                    |
+-----------------------+------------------------------------------------------------------------------------+


**QtDemoApp**

.. |img_demo| image:: ../../images/example_qt_demoapp.png
   :width: 150

+-----------------------+------------------------------------------------------------------------------------+
| |img_demo|            | **Location**\ : Examples/Qt/QtDemoApp |br|                                         |
|                       | A small Post Processor written in Qt to showcase some of the features in the  |br| |
|                       | UnstructGrid component.                                                            |
+-----------------------+------------------------------------------------------------------------------------+

