1 (edited by plc-user 2024-06-06 14:59:57)

Topic: Element-Editor: Edit-Field for X-/Y-Position of terminals loses focus

Hello everybody!

In Element-Editor the Edit-Fields (SpinBoxes) for X- and Y-Position of terminals lose focus every time a key on the keyboard is hit. That makes editing the position with keyboard very annoying!

Trying to fix that, I edited the QET-Sources a bit and now I need someone to check, whether there are any side-effects.
For me it seems to work, but my Qt-Knowledge is very restricted, so I don't know if there may be something wrong.
Actually it compiles without warning!

Here's what I changed:

diff --git a/sources/editor/ui/terminaleditor.cpp b/sources/editor/ui/terminaleditor.cpp
index c84ae5ecf..77e0c2112 100644
--- a/sources/editor/ui/terminaleditor.cpp
+++ b/sources/editor/ui/terminaleditor.cpp
@@ -219,9 +219,9 @@ void TerminalEditor::activeConnections(bool active)
     if (active) {
         m_editor_connections << connect(ui->m_x_dsb, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
-                                        this, &TerminalEditor::posEdited);
+                                        [this]() { TerminalEditor::posEdited(); ui->m_x_dsb->setFocus();} ) ;
         m_editor_connections << connect(ui->m_y_dsb, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
-                                        this, &TerminalEditor::posEdited);
+                                        [this]() { TerminalEditor::posEdited(); ui->m_y_dsb->setFocus(); } ) ;
         m_editor_connections << connect(ui->m_orientation_cb,  QOverload<int>::of(&QComboBox::activated),
                                         this, &TerminalEditor::orientationEdited);
         m_editor_connections << connect(ui->m_name_le, &QLineEdit::editingFinished,

Could someone please use this diff to check, if it's ok?
Maybe you, Laurent?

In case that code works without side-effects I would create a pull-request on GitHub.

Thanks in advance!

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Element-Editor: Edit-Field for X-/Y-Position of terminals loses focus

Hallo plc-user,

I'm not sure the code is perfect, but it's a lot better now for using the spinboxes with the keyboard's arrow keys and or numeric keypad.
Then we'll see how well it compiles on other compilers.

As for side effects, I don't see what they could be.

Best regards,

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."