Clone
2
element_editor
ispyisail edited this page 2026-09-19 17:31:34 +12:00

Using the element editor

Linking elements documents the .elmt file that results from element authoring — master/slave/terminal, contact groups, information flags. This page documents the other half: actually drawing an element in QET's built-in editor.

Source: sources/editor/ (~22,900 lines) — qetelementeditor.cpp (the window), elementscene.cpp (the canvas), graphicspart/ (one class per drawable primitive), esevent/ (the interactive placement tools), ui/ (the property panels).


1. Starting an element

New element opens a three-step wizard:

  1. Parent category — where in the collection tree the element will live.
  2. File name — the *.elmt extension is added automatically if you leave it off.
  3. Name(s) — the element's display name, one per language; only your current UI language is required, the rest can be filled in later.

The editor opens on an empty canvas. There is no separate "set the element's size" step — see §3.

You can also open an existing element to edit it, or start from a DXF file imported as line art into a new element via File → Import a DXF file — a way to trace CAD geometry rather than draw from scratch.


2. The drawing tools

One toolbar button per primitive type:

Tool Draws
Line a straight segment
Rectangle click-drag a corner-to-corner rectangle
Ellipse click-drag a bounding box
Polygon click each vertex; double-click to finish, right-click to undo the last point
Arc a circular arc
Text a fixed label, not editable once placed on a diagram
Dynamic text field a text item that can be edited per-instance on a diagram — this is what element information and formula variables attach to, see Variables & formulas
Terminal a connection point

Placing terminals

A terminal needs an orientation — which side of the body it points out of, and therefore which direction a wire may approach it from. While placing one, press Space to rotate it through the four cardinal directions before clicking to commit.

After you place a terminal, the tool immediately starts another one at the same orientation — convenient for a row of same-facing pins. Right-click ends the tool.

Terminal type and function (generic, fuse, diode, ground…) are set afterward in the terminal's own properties, not while placing it — see Linking elements §4.


3. Width, height and hotspot are computed, not typed

There is no dialog where you enter the element's width, height or hotspot. They are derived automatically from whatever you've drawn, recalculated on every save:

  • The bounding rectangle of every primitive on the canvas is measured.
  • Width and height are rounded up to the next multiple of 10 — with a quirk: if the remainder is more than 6, it rounds up an extra ten. A drawing 42 px wide becomes 50 (this is the exact case Elements XML uses as its rounding example — now you know where the number comes from).
  • The hotspot is placed at the centre of that rounded bounding box.

The gotcha: drawing away from the scene origin moves your parts

If your drawing doesn't straddle the scene's origin point (0,0), QET re-centres every primitive on save so that it does — parts actually move on the canvas, not just in the saved coordinates. Draw comfortably near the crosshair at the canvas centre and this never surprises you; draw far off to one side and a save can visibly shift everything.


4. Saving

Three related actions, easy to confuse:

Action Destination
Save wherever the element was opened from — a collection location if opened from the elements panel, a plain file path if opened by file
Save As asks for a collection location (category + name), the normal way to save a new element into your custom collection
Save As File asks for a plain filesystem path, outside any collection

All three run the same validation first (§5); a failed check blocks the save and none of them writes anything.


5. What's checked before saving

QET validates the element and reports problems as either a warning (save proceeds) or an error (save is blocked):

Condition Severity
No terminals at all warning — unless the element is a folio report, a conductor definition, or a thumbnail, which are allowed to have none
A folio report element has anything other than exactly one terminal error
A conductor definition element has anything other than exactly one terminal error

An element with zero terminals still saves — you'll just get a dialog telling you it can't be wired to anything, which is sometimes exactly what you want (a thumbnail, a text block, a title-block decoration).


6. The panels around the canvas

Panel What it gives you
Parties every primitive in the element, as a list. Selecting in the list selects on the canvas and the other way round — the reliable way to reach a primitive buried under another one
Profondeur the stacking order. A filled shape drawn last hides what is under it; this is where you push it back
Status bar a live X / Y readout of the pointer, in the element's own coordinates

The parts list gives up past 200 primitives. Above that it shows "Trop de primitives, liste non générée" with the count instead of the list, because building it for a very complex element is slow. The element is fine and still editable — only the list is withheld. The ceiling is the setting elementeditor/max-parts-element-editor-list, so it can be raised if you routinely draw elements that big.


7. Getting drawings in and out

Action What it does
Importer un élément à redimensionner opens another .elmt and brings it in so you can scale it — the way to build a variant of an existing symbol rather than redrawing it
Importer un fichier dxf brings DXF geometry in as primitives — see DXF import & export
Exporter en SVG writes the element out as an SVG image, for documentation rather than for QElectroTech
Recharger l'élément re-reads the element from disk. If you have unsaved changes it warns first, and says plainly that reloading loses them

An element opened from a collection you cannot write to opens read-only: the title bar says so, and saving is refused. Use Save as to put a copy somewhere writable — see Managing collections for which collections are writable.


8. Reshaping a primitive

Select a primitive and drag its handles. The modifiers are the same ones the diagram editor uses, and they are worth knowing here because the element editor is where you use them most:

Hold While dragging
Ctrl ignore the grid — fine positioning
Shift keep proportions when resizing; snap to 15° when rotating or skewing
Alt on a corner turn a rectangle or an ellipse into a polygon, so each corner moves on its own

The full list is on Mouse modifiers.


9. Beyond the basics

  • PLC master tables. Setting a master element's type to PLC replaces the usual contact-budget controls with an interactive I/O table — see Linking elements §5. No element in the shipped collection currently uses this.
  • Line style (weight, colour, dash pattern) is set per-primitive from its own properties panel, not the toolbar.
  • Grid and snap work the same way as the diagram editor.

See also: Linking elements · Elements XML · DXF import & export · Variables & formulas · Mouse modifiers · Managing collections