GNU TeXmacsUser manualReferenceAboutEnglish
The Qt port: versions, keyboard, clipboards and printing

The structure of the Qt port (widgets, UI elements, menus, the event queue, windows, canvases) is described in the Qt implementation, and its renderer in the renderer implementations. This page adds what is specific to the Qt versions and to the input and output channels of the port.

1.Qt 4, 5 and 6

Plugins/Qt compiles with Qt 4, 5 and 6. The differences are handled by about 270 tests of QT_VERSION in the port (most of them QT_VERSION >= 0x060000, < 0x060000 and >= 0x050000) and by a few outside it, for instance in

Texmacs/Texmacs/texmacs.cpp

,

Texmacs/Window/tm_button.cpp

,

Edit/Interface/edit_interface.cpp

and

System/Files/web_files.cpp

. Notable differences are:

gui_version () returns "qt4", "qt5" or "qt6" accordingly (

qt_gui.cpp

). The same code is in

Plugins/Qt6

and in Qtwk (

qtwk_gui.cpp

), so gui-version does not tell Qtwk from Qt. The predicate qt-gui? holds in the two Qt directories and in the Cocoa port, but not in Qtwk, whose widgets are those of Widkit (there x-gui? holds, as in X11), see the overview.

2.The
Plugins/Qt6
fork

Plugins/Qt6

was created on 2026-05-27 as a copy of Plugins/Qt (commit 73253e50f1, “duplicating qt folder”) and is compiled instead of it by configure --enable-qt-new, which requires Qt 6.10 (see selecting and building a port). Compared with Plugins/Qt it

The two directories are kept in sync by hand: changes made in Plugins/Qt are copied over in commits such as bb309fcd50 (“propagating change from Qt dir to Qt6 dir”). A fix in one directory therefore has to be made in the other one too.

3.Keyboard and input methods

Key presses arrive in QTMWidget::keyPressEvent (

QTMWidget.cpp

). A QTMKeyboardEvent translates the Qt key code, modifiers and text into a TeXmacs key combination such as "C-x" or "A-S-left", using the global keyboard settings of QTMKeyboard (

QTMKeyboard.hpp

, held by the application object). An empty combination means that the key is ignored. Otherwise qt_gui_rep::process_keypress queues a QP_KEYPRESS event, which the event loop later delivers to the editor; from there on the key is handled by the keyboard configuration of the server, see keyboard configuration.

Input methods (accents, Chinese and Japanese input, the macOS character palette, dictation) go through QTMWidget::inputMethodEvent:

For Qt 4 on macOS, a table in inputMethodEvent converts the committed characters of a few Option key combinations back into key presses; this hack only works for standard US keyboards.

4.Clipboards

The TeXmacs clipboards are named; the Qt port maps "primary" to the system clipboard (QClipboard::Clipboard) and "mouse" to the selection clipboard of X11 (QClipboard::Selection) when the platform supports it. All other names are purely internal: they are stored in the hash tables selection_t and selection_s of qt_gui_rep and never reach the system.

Copying.
qt_gui_rep::set_selection (key, t, s, sv, sh, format) stores the tree and its serialization locally and then publishes a QMimeData. For the format default it contains the TeXmacs snippet under the private type application/x-texmacs-clipboard, the process id under application/x-texmacs-pid, and the verbatim version sv as plain text (in the encoding of the preference texmacs->verbatim:encoding). For the formats html and latex the converted text is published as HTML or plain text. The caller, edit_select_rep::selection_set (
Edit/Replace/edit_select.cpp

), computes sv for the format default in every port; Qtwk publishes the same QMimeData (qtwk_gui_rep::set_selection).

Pasting.
qt_gui_rep::get_selection first decides whether TeXmacs owns the clipboard, by comparing the application/x-texmacs-pid entry with its own process id; if so, the local copy is returned unchanged. Otherwise, for the format default, it picks the richest available representation, in this order: a TeXmacs snippet of another instance, an image (a single URL becomes a linked image, other image data is converted to PNG and embedded), HTML (after repairing known bugs of some browsers with correct_buggy_html_paste), and plain text. The result is converted to a TeXmacs snippet by the Scheme function convert and returned as (extern snippet). The pseudo clipboard "extern" reads the system clipboard without this conversion.

5.Printing

print-buffer (

texmacs/texmacs/tm-files.scm

) uses a dialog only if use-print-dialog? holds, that is, when qt-gui? or vue-gui? holds and the preference gui:print dialogue is on. Otherwise it calls print, which typesets the document to PostScript or PDF and sends the file to the printing command (set-printing-command).

With the dialog, interactive-print-buffer first prints to the file $TEXMACS_HOME_PATH/system/tmp/tmpprint.suffix and then opens widget-printer in an alternative window (interactive-print in

kernel/gui/menu-widget.scm

). In Qt this widget is a qt_printer_widget_rep (

qt_printer_widget.cpp

) showing a QTMPrintDialog. As the comment of that file says, all options are applied as a postprocessing of the already typeset file: QTMPrinterSettings::toSystemCommand turns them into a command line which is run with qt_system. On macOS and Linux the settings class is CupsQTMPrinterSettings, which queries the printers with lpoptions (asynchronously, since it may use the network) and prints with the printing command of TeXmacs or lp and CUPS options (-o orientation-requested, -o sides, -o number-up, -o page-ranges, …); on Windows it is WinQTMPrinterSettings.

The other ports with a print dialog have their own printer_widget: Vue a dialog of Clay widgets which also queries lpoptions and prints with lpr (the Vue port), and Cocoa the print panel of macOS (the Cocoa port). In Qtwk, qt-gui? does not hold, so use-print-dialog? is false and the Widkit placeholder printer_widget is never opened: printing goes through the printing command, as in X11.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".