pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
Window::QmlBridge Class Reference

Bridge class to expose C++ functionality to QML. More...

#include <qml_bridge.hpp>

Inheritance diagram for Window::QmlBridge:
Inheritance graph
Collaboration diagram for Window::QmlBridge:
Collaboration graph

Public Slots

void showAbout ()
 Slot to display the "About" dialogue. More...
 
void showAboutQt ()
 Slot to display the "About Qt" dialogue. More...
 
void quit ()
 Slot to quit the application. More...
 

Signals

void displayContainerChanged ()
 Emitted when the display container is created.
 
void aboutTextChanged ()
 Emitted when the about text changes.
 
void simulationFinished ()
 Emitted when the simulation finishes.
 

Public Member Functions

 QmlBridge (const Configuration::SimulationConfig &config, QObject *parent=nullptr)
 Constructs the QML bridge. More...
 
 ~QmlBridge () override
 Destructor. More...
 
QWidget * displayContainer () const
 Gets the widget container for the 3D display. More...
 
QString aboutText () const
 Gets the "About" page text. More...
 
Q_INVOKABLE void startSimulation ()
 Starts the simulation after the window is shown. More...
 
Q_INVOKABLE void cleanup ()
 Triggers cleanup of child components (stops threads, prints reports). More...
 
void releaseDisplay ()
 Releases the Display (destroys it manually). This must be called before the container is destroyed to avoid segfaults when the container tries to access the Display during destruction. More...
 
void releaseDisplayDeferred (QWidget *container_for_deferred_delete)
 Releases the Display using deferred destruction. More...
 

Properties

QWidget * displayContainer
 
QString aboutText
 

Private Member Functions

std::optional< QString > loadAboutText ()
 Loads the "About" page content from resources. More...
 

Private Attributes

std::unique_ptr< Displaydisplay_
 The 3D display view for the simulation. More...
 
QWidget * container_
 The widget container for the 3D display. More...
 
QString aboutText_
 The cached about text. More...
 

Detailed Description

Bridge class to expose C++ functionality to QML.

This class acts as an interface between QML and the C++ backend, exposing the Display widget and application actions (About, Quit).

Definition at line 44 of file qml_bridge.hpp.

Constructor & Destructor Documentation

◆ QmlBridge()

Window::QmlBridge::QmlBridge ( const Configuration::SimulationConfig &  config,
QObject *  parent = nullptr 
)
explicit

Constructs the QML bridge.

Parameters
configThe simulation configuration object.
parentThe parent QObject.

Definition at line 33 of file qml_bridge.cpp.

Here is the call graph for this function:

◆ ~QmlBridge()

Window::QmlBridge::~QmlBridge ( )
override

Destructor.

Definition at line 66 of file qml_bridge.cpp.

Member Function Documentation

◆ aboutText()

QString Window::QmlBridge::aboutText ( ) const

Gets the "About" page text.

Returns
The about text as a QString.

Definition at line 75 of file qml_bridge.cpp.

◆ cleanup()

void Window::QmlBridge::cleanup ( )

Triggers cleanup of child components (stops threads, prints reports).

Definition at line 83 of file qml_bridge.cpp.

◆ displayContainer()

QWidget * Window::QmlBridge::displayContainer ( ) const

Gets the widget container for the 3D display.

Returns
A pointer to the widget container, or nullptr if not created.

Definition at line 73 of file qml_bridge.cpp.

◆ loadAboutText()

std::optional< QString > Window::QmlBridge::loadAboutText ( )
private

Loads the "About" page content from resources.

Returns
The content of the about page as a QString, or std::nullopt if loading fails.

Definition at line 131 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ quit

void Window::QmlBridge::quit ( )
slot

Slot to quit the application.

Definition at line 129 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ releaseDisplay()

void Window::QmlBridge::releaseDisplay ( )

Releases the Display (destroys it manually). This must be called before the container is destroyed to avoid segfaults when the container tries to access the Display during destruction.

Definition at line 91 of file qml_bridge.cpp.

◆ releaseDisplayDeferred()

void Window::QmlBridge::releaseDisplayDeferred ( QWidget *  container_for_deferred_delete)

Releases the Display using deferred destruction.

This schedules destruction with deleteLater() to avoid blocking the caller during heavy Qt3D teardown. If a container is provided, its deletion is chained to Display destruction, guaranteeing that Display is destroyed first.

Definition at line 100 of file qml_bridge.cpp.

◆ showAbout

void Window::QmlBridge::showAbout ( )
slot

Slot to display the "About" dialogue.

Definition at line 119 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ showAboutQt

void Window::QmlBridge::showAboutQt ( )
slot

Slot to display the "About Qt" dialogue.

Definition at line 125 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ startSimulation()

void Window::QmlBridge::startSimulation ( )

Starts the simulation after the window is shown.

Definition at line 77 of file qml_bridge.cpp.

Member Data Documentation

◆ aboutText_

QString Window::QmlBridge::aboutText_
private

The cached about text.

Definition at line 149 of file qml_bridge.hpp.

◆ container_

QWidget* Window::QmlBridge::container_
private

The widget container for the 3D display.

Definition at line 146 of file qml_bridge.hpp.

◆ display_

std::unique_ptr<Display> Window::QmlBridge::display_
private

The 3D display view for the simulation.

Definition at line 143 of file qml_bridge.hpp.

Property Documentation

◆ aboutText

QString Window::QmlBridge::aboutText
read

Definition at line 1 of file qml_bridge.hpp.

◆ displayContainer

QWidget* Window::QmlBridge::displayContainer
read

Definition at line 1 of file qml_bridge.hpp.


The documentation for this class was generated from the following files: