The interface between QCustomPlot and QTextDocument is QCPDocumentObject. More information can be found at https://www.qcustomplot.com/index.php/tutorials/specialcases/textdocument
git clone https://github.com/zohannn/qcpdocumentobject.git
cd qcpdocumentobject
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
cmake -DCMAKE_BUILD_TYPE=Release ..
make