From 3457a88e81756446b952e99d30d2cfc7e1a0fe97 Mon Sep 17 00:00:00 2001 From: Kellermorph Date: Wed, 23 Sep 2026 10:28:00 +0200 Subject: [PATCH] Open the PLC master properties dialog at three times its width Element::editProperty() gave PropertiesEditorDialog no size of its own, so the dialog fell back to its sizeHint, which is sized for the compact general-purpose editors it usually hosts. A PLC master instead shows a six-column IO table that grows horizontally, and the dialog came out too narrow to read those columns in. For a master whose type is PLC, resize the dialog to three times its natural width before exec(), keeping the natural height. The width is clamped to the available screen so it cannot run off the display, and every other element type opens exactly as before. --- sources/qetgraphicsitem/element.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index a42f5ee64..f0d09639d 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -39,7 +39,9 @@ #include "elementtextitemgroup.h" #include "iostream" +#include #include +#include static const QString plcTerminalKeys[] = { QETInformation::ELMT_PLC_T1, @@ -209,6 +211,21 @@ void Element::editProperty() //with the "text" tab of ElementPropertiesWidget, //the ui freeze, until user press escape key dialog.setWindowModality(Qt::WindowModal); + + // A PLC master carries a 6-column IO table: without an explicit + // size the dialog falls back to its (cramped) sizeHint, so open it + // at three times its natural width instead. The height stays at + // the natural one, and the width never exceeds the screen. + const ElementData data = elementData(); + if (data.m_type == ElementData::Master + && data.m_master_type == ElementData::PLC) { + const QSize natural = dialog.sizeHint(); + int width = natural.width() * 3; + if (QScreen *screen = QApplication::primaryScreen()) + width = qMin(width, screen->availableGeometry().width()); + dialog.resize(width, natural.height()); + } + dialog.exec(); } }