Skip to content

[EXPERIMENTAL] Introduce Qt6-based implementation for TCanvasImp [skip-ci]#22736

Draft
linev wants to merge 20 commits into
root-project:masterfrom
linev:qt6_canvas
Draft

[EXPERIMENTAL] Introduce Qt6-based implementation for TCanvasImp [skip-ci]#22736
linev wants to merge 20 commits into
root-project:masterfrom
linev:qt6_canvas

Conversation

@linev

@linev linev commented Jul 1, 2026

Copy link
Copy Markdown
Member

It is early prototype, please DO NOT MERGE yet.

After setting Gui.Factory: qt6 Qt6-based canvas will be used in ROOT.

Painting with TQt6PadPainter redirected to QPainter class where all ROOT primitives - polyline, fillarea, polymarkers, line, box, text - are implemented.
Different mouse click/move/release events are processed.
Menu implemented with QMenuBar, status line with QStatusBar.

Also context menu is implemented providing TContextMenuImp class.
It includes special dialog for input of method parameters.
Also toggle menu item with checked states should work.

Provided implementation fully avoids gVirtualX usage - pure Qt graphics is used.
TQt6Canvas works now with basic primitives like TLatex, TLine, TBox
and with TH1/TH2 classes in 2D and 3D plots.
Some ROOT classes may crash while they internally use gVirtualX for event handling.

This is first (but not the only) new graphical backend which can fully replace gVirtualX-based implementation.
After finalizing of API some other - more simpler (like raylib) or more advanced (like Vilkan) - can be exercised.

@linev linev self-assigned this Jul 1, 2026
@linev linev requested a review from bellenot as a code owner July 1, 2026 10:41
@linev linev requested review from dpiparo and pcanal as code owners July 1, 2026 10:41
@linev linev added in:Graphics skip ci Skip the full builds on the actions runners labels Jul 1, 2026
@linev linev marked this pull request as draft July 1, 2026 10:41
linev added 16 commits July 2, 2026 09:45
These will be core classes to provide Qt6 graphics independent from TVirtualX
Up to now only TRootCanvas and TWebCanvas are supported -
all other classes were ignored.

Now try to load plugin when something different from TRootCanvas is specified.
Also in batch mode use of external canvas should be possible
It implements Qt6 widget with menu, status line and canvas paint area.
Details to be implemented
It is specialized QWidget which will handle
paint area for the canvas.

Start with resize handler to track changes in
canvas width and height.
In the Qt one cannot start painting on the canvas
in the arbitrary moment - one only can do this inside
paintEvent() handler. Therefore only there call
pad->Paint method which will invoke correct painting inside

Because of this canvas->Update() does not call directly
Paint() but uses QWidget::update() which invalidates
paint area and invokes paintEvent then.

Start implementation of TQt6PadPainter with text drawing.
One can use TTF directly with Qt without need to extra handle
of fonts ourselfs. Handle color and rotation as well
While text painting done with QFont,
also text metrics implement with QFont functionality
Handle TAttLine with custom colors, width and style
Create QPen which contains such properties
Support special fill patterns 3000..3025 reusing X11 pixmaps
Implement box and fillarea painting
Once generic API exists to paint markers -
use it here instead. There are 5 different places
in ROOT which repeats again and again all markers implementation
It is not equivalent with TTF font and must be about 0.75
Use QString::toLatin1() method, otherwise special characters
like used in symbols.ttf, are handled as utf-8 as displayed wrongly
Like press, move, release mouse button.
On the right mouse button actiate context menu.
For methods with arguments provide special dialog.

Code partially copied from Go4 project
and originally was developed in 2002
by Denis Bertini and improved later by Sergey Linev
linev added 4 commits July 2, 2026 10:44
It fully dismiss standard GUI classes and
only allows to create Qt6canvas.
Aim to provide specialized implementation for
application and context menu
It is implementation for context menu used inside qt6_canvas
Idea to let handle right mouse button click in the
canvas handler which will invoke implementation class
This is default place where all normal or custom items
for the class are collected. By large copy code from
TRootContextMenu.
Reuse several methods from TContextMenu to
create labels for arguments and afterwards
execute selected method with provided list of arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects:master in:Graphics skip ci Skip the full builds on the actions runners

1 participant