Embed TCanvas in Qt

Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

ROOT Version: 6.28
Platform: windows 10
Compiler: visual C++

I can’t embed TCanvas in Qt via " How to Embed a TCanvas in External Applications? - Howto - ROOT Forum (cern.ch)".
I do not know how to do “int wid = gVirtualX->AddWindow((ULong_t)getid(), getWidth(), getHeight());” and so on.
I hope send me a sample tutorial, so that I can embed TCanvas in Qt easily.

Hi @songshusen,

maybe this helps:

Note that TCanvas will be replaced by the new web-based RCanvas to be more platform independent.

Does this tutorial answer your questions?


Old method of embeding ROOT canvas in QWindow no longer working on Mac and Windows platforms.
It is still possible to use it on X11-based platforms like Linux.

The only portable solution for now - using new TWebCanvas. tutorials/webgui/qtweb shows how it can be done.


QWebEngineView, I can’t find it to include.
it is the module in Qt?

You need to install qt WebEngine developer components.

For me (OpenSUSE) packet called libqt5-qtwebengine-devel

auto where = ROOT::RWebDisplayArgs::GetQt5EmbedQualifier(this, “noopenui”, QT_VERSION);
if Qt6 could do it?

Code was originally developed with Qt5, but now also works with Qt6 components.
That’s why QT_VERSION has to be provided.

auto where = ROOT::RWebDisplayArgs::GetQt5EmbedQualifier(this, “noopenui”, QT_VERSION);
with visual c++, No member named ‘RWebDisplayArgs’ in namespace ‘ROOT’.
I have include “ROOT/RWebDisplayArgs.hxx”.
where may be not right?

Did you compile ROOT with webgui and qt5web/qt6web support?

See readme file in qtweb directory:

I can not open //github.com/root-project/root/tree/master/tutorials/webgui/qtweb.
Could you share it to me in anther way?

Strange, I just copied link to github repository.

Seems to be forum brakes links on github

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.