From 4e361f93fe717b05a284dd29319e91a9b574c7ea Mon Sep 17 00:00:00 2001 From: Kellermorph Date: Wed, 23 Sep 2026 10:27:50 +0200 Subject: [PATCH 1/2] Let the PLC master IO table columns be resized, and remember the layout The IO table of MasterPropertiesWidget -- the panel that opens when a PLC master placed on a schematic is edited -- set every section to QHeaderView::Stretch. Stretch spreads the sections evenly over the widget and disables section dragging altogether, so the column boundaries were permanently fixed: they could be neither widened nor narrowed, and only the width of the whole panel had any effect. Use QHeaderView::Interactive instead, with movable sections and a set of default widths, so the columns can be dragged as they are everywhere else in the application. The layout reached this way is written to QSettings under masterpropertieswidget/plc-table-header-state on every sectionResized and sectionMoved, and restored the next time the table is built -- the same header-state trick the free and linked element trees of this widget already use, except saved automatically rather than only from the context menu. --- sources/ui/masterpropertieswidget.cpp | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/sources/ui/masterpropertieswidget.cpp b/sources/ui/masterpropertieswidget.cpp index 339938d06..94d56e145 100644 --- a/sources/ui/masterpropertieswidget.cpp +++ b/sources/ui/masterpropertieswidget.cpp @@ -539,7 +539,35 @@ void MasterPropertiesWidget::updateUi() tr("Type"), tr("Adresse"), tr("Fonction"), tr("Commentaire"), tr("Réf. croisée"), tr("Bornes") }); - m_plc_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + m_plc_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + m_plc_table->horizontalHeader()->setSectionsMovable(true); + m_plc_table->horizontalHeader()->resizeSection(0, 120); + m_plc_table->horizontalHeader()->resizeSection(1, 100); + m_plc_table->horizontalHeader()->resizeSection(2, 150); + m_plc_table->horizontalHeader()->resizeSection(3, 150); + m_plc_table->horizontalHeader()->resizeSection(4, 100); + m_plc_table->horizontalHeader()->resizeSection(5, 120); + + // Restore a previously saved column layout, if any + auto *plc_hdr = m_plc_table->horizontalHeader(); + QSettings plc_settings; + const QVariant plc_hdr_state = plc_settings.value( + QStringLiteral("masterpropertieswidget/plc-table-header-state")); + if (!plc_hdr_state.isNull()) + plc_hdr->restoreState(plc_hdr_state.toByteArray()); + + // Persist the column layout whenever the user resizes or moves a column + auto save_plc_header_state = [plc_hdr]() + { + QSettings settings; + settings.setValue(QStringLiteral("masterpropertieswidget/plc-table-header-state"), + plc_hdr->saveState()); + }; + connect(plc_hdr, &QHeaderView::sectionResized, + this, save_plc_header_state); + connect(plc_hdr, &QHeaderView::sectionMoved, + this, save_plc_header_state); + m_plc_table->setSelectionBehavior(QAbstractItemView::SelectItems); m_plc_table->setSelectionMode(QAbstractItemView::ExtendedSelection); m_plc_table->setMinimumHeight(200); From 3457a88e81756446b952e99d30d2cfc7e1a0fe97 Mon Sep 17 00:00:00 2001 From: Kellermorph Date: Wed, 23 Sep 2026 10:28:00 +0200 Subject: [PATCH 2/2] 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(); } }