Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Invisible QLineEdit receive Focus?!?
Forum Updated to NodeBB v4.3 + New Features

Invisible QLineEdit receive Focus?!?

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    django.Reinhard
    wrote on last edited by
    #1

    Hi,

    I have an editor with variable field count (depending on situation). That means, I load the editor from ui-file and then programmatically hide the elements, that should actually not be visible.

    When I use the editor and switch with tab-key through all active elements - the focus disappears on any hidden entry.
    Or otherwise said - suppose I have 10 entry fields and hide #6-8 - then at field 5 I have to press 3 times the tab-key until the focus reaches next visible entry field.

    Any idea for a workaround?

    JonBJ eyllanescE 2 Replies Last reply
    0
    • D django.Reinhard

      Hi,

      I have an editor with variable field count (depending on situation). That means, I load the editor from ui-file and then programmatically hide the elements, that should actually not be visible.

      When I use the editor and switch with tab-key through all active elements - the focus disappears on any hidden entry.
      Or otherwise said - suppose I have 10 entry fields and hide #6-8 - then at field 5 I have to press 3 times the tab-key until the focus reaches next visible entry field.

      Any idea for a workaround?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @django-Reinhard
      Although I have never tried this, it does not sound right. Do you hide your QLineEdits via lineEdit->hide()? I would expect the tab key to skip such elements. Do you have just plain QLineEdits on some simple layout, or do you have something like they are inside a QTableWidget?

      1 Reply Last reply
      1
      • D django.Reinhard

        Hi,

        I have an editor with variable field count (depending on situation). That means, I load the editor from ui-file and then programmatically hide the elements, that should actually not be visible.

        When I use the editor and switch with tab-key through all active elements - the focus disappears on any hidden entry.
        Or otherwise said - suppose I have 10 entry fields and hide #6-8 - then at field 5 I have to press 3 times the tab-key until the focus reaches next visible entry field.

        Any idea for a workaround?

        eyllanescE Offline
        eyllanescE Offline
        eyllanesc
        wrote on last edited by
        #3

        @django-Reinhard please provide a verifiable example.

        If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

        1 Reply Last reply
        1
        • D Offline
          D Offline
          django.Reinhard
          wrote on last edited by
          #4

          @JonB said in Invisible QLineEdit receive Focus?!?:

          Do you have just plain QLineEdits on some simple layout ...

          Yes, QLineEdit with QGridLayout ...

          @eyllanesc said in Invisible QLineEdit receive Focus?!?:

          please provide a verifiable example.

          Sorry, but that would be too much work.
          Look:

          Fixture013.jpg

          The App consists of a center widget and several dockables. Center-widget is a stack and here the main widget of the QScrollArea manages 10 Editors in a FlowLayout.
          My goal was to make the application usable without a mouse. This led to some peculiarities that are not known from mouse applications.

          ... any way:
          The number of QLineEdits is based on values read from ini-file and processed by some intermediate classes ... too complex to simplify in a hurry

          The editor was created by form-designer of QtCreator and consists of QLabel, QLineEdit and QGridLayout. Taborder was specified in QtCreator too.

          The editor class (only problem related parts):

          #include <dynwidget.h>
          #include <ui_Fixture.h>
          class QLineEdit;
          class AxisMask;
          
          
          class FixtureEdit : public DynWidget // , protected Ui_frame
          {
          public:
            FixtureEdit(const QString& title, const AxisMask& mask, QWidget* parent = nullptr);
          
          protected:
            void setupUi(DynWidget* parent);
          
          private:
            Ui::frame*      ui;
            const AxisMask& m;
            };
          

          constructor ...

          FixtureEdit::FixtureEdit(const QString& title, const AxisMask& mask, QWidget* parent)
           : DynWidget(QString(), parent)
           , ui(new Ui::frame())
           , m(mask) {
            setupUi(this);
            ui->title->setText(title);
            layout()->setContentsMargins(0, 0, 0, 0);
            }
          

          ... and setupUi (lX is a QLabel and edX the QLineEdit):

          void FixtureEdit::setupUi(DynWidget* parent) {
            ui->setupUi(parent);
            ui->lX->setVisible(m.hasXAxis());
            ui->lY->setVisible(m.hasYAxis());
            ui->lZ->setVisible(m.hasZAxis());
            ui->lA->setVisible(m.hasAAxis());
            ui->lB->setVisible(m.hasBAxis());
            ui->lC->setVisible(m.hasCAxis());
            ui->lU->setVisible(m.hasUAxis());
            ui->lV->setVisible(m.hasVAxis());
            ui->lW->setVisible(m.hasWAxis());
            ui->edX->setVisible(m.hasXAxis());
            ui->edY->setVisible(m.hasYAxis());
            ui->edZ->setVisible(m.hasZAxis());
            ui->edA->setVisible(m.hasAAxis());
            ui->edB->setVisible(m.hasBAxis());
            ui->edC->setVisible(m.hasCAxis());
            ui->edU->setVisible(m.hasUAxis());
            ui->edV->setVisible(m.hasVAxis());
            ui->edW->setVisible(m.hasWAxis());
            }
          

          last not least the ui-file:

          <?xml version="1.0" encoding="UTF-8"?>
          <ui version="4.0">
           <class>frame</class>
           <widget class="DynWidget" name="frame">
            <property name="geometry">
             <rect>
              <x>0</x>
              <y>0</y>
              <width>233</width>
              <height>336</height>
             </rect>
            </property>
            <property name="sizePolicy">
             <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
              <horstretch>0</horstretch>
              <verstretch>0</verstretch>
             </sizepolicy>
            </property>
            <property name="lineWidth" stdset="0">
             <number>3</number>
            </property>
            <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0" columnstretch="0,0">
             <property name="leftMargin">
              <number>0</number>
             </property>
             <property name="topMargin">
              <number>0</number>
             </property>
             <property name="rightMargin">
              <number>0</number>
             </property>
             <property name="bottomMargin">
              <number>0</number>
             </property>
             <property name="verticalSpacing">
              <number>1</number>
             </property>
             <item row="5" column="1">
              <widget class="QLineEdit" name="edA">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="7" column="0">
              <widget class="QLabel" name="lC">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>C</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="8" column="1">
              <widget class="QLineEdit" name="edU">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="10" column="1">
              <widget class="QLineEdit" name="edW">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="3" column="0">
              <widget class="QLabel" name="lY">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>Y</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="6" column="1">
              <widget class="QLineEdit" name="edB">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="2" column="1">
              <widget class="QLineEdit" name="edX">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="2" column="0">
              <widget class="QLabel" name="lX">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>X</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="10" column="0">
              <widget class="QLabel" name="lW">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>W</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="4" column="0">
              <widget class="QLabel" name="lZ">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>Z</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="9" column="1">
              <widget class="QLineEdit" name="edV">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="9" column="0">
              <widget class="QLabel" name="lV">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>V</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="8" column="0">
              <widget class="QLabel" name="lU">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>U</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="7" column="1">
              <widget class="QLineEdit" name="edC">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="6" column="0">
              <widget class="QLabel" name="lB">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>B</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="4" column="1">
              <widget class="QLineEdit" name="edZ">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="3" column="1">
              <widget class="QLineEdit" name="edY">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
              </widget>
             </item>
             <item row="5" column="0">
              <widget class="QLabel" name="lA">
               <property name="minimumSize">
                <size>
                 <width>25</width>
                 <height>0</height>
                </size>
               </property>
               <property name="text">
                <string>A</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
             <item row="1" column="0" colspan="2">
              <widget class="QLabel" name="title">
               <property name="sizePolicy">
                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="font">
                <font>
                 <pointsize>12</pointsize>
                 <weight>75</weight>
                 <bold>true</bold>
                </font>
               </property>
               <property name="frameShape">
                <enum>QFrame::Panel</enum>
               </property>
               <property name="frameShadow">
                <enum>QFrame::Raised</enum>
               </property>
               <property name="text">
                <string>G54</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
            </layout>
           </widget>
           <customwidgets>
            <customwidget>
             <class>DynWidget</class>
             <extends>QWidget</extends>
             <header>dynwidget.h</header>
             <container>1</container>
            </customwidget>
           </customwidgets>
           <tabstops>
            <tabstop>edX</tabstop>
            <tabstop>edY</tabstop>
            <tabstop>edZ</tabstop>
            <tabstop>edA</tabstop>
            <tabstop>edB</tabstop>
            <tabstop>edC</tabstop>
            <tabstop>edU</tabstop>
            <tabstop>edV</tabstop>
            <tabstop>edW</tabstop>
           </tabstops>
           <resources/>
           <connections/>
          </ui>
          
          JonBJ Cobra91151C 2 Replies Last reply
          0
          • D django.Reinhard

            @JonB said in Invisible QLineEdit receive Focus?!?:

            Do you have just plain QLineEdits on some simple layout ...

            Yes, QLineEdit with QGridLayout ...

            @eyllanesc said in Invisible QLineEdit receive Focus?!?:

            please provide a verifiable example.

            Sorry, but that would be too much work.
            Look:

            Fixture013.jpg

            The App consists of a center widget and several dockables. Center-widget is a stack and here the main widget of the QScrollArea manages 10 Editors in a FlowLayout.
            My goal was to make the application usable without a mouse. This led to some peculiarities that are not known from mouse applications.

            ... any way:
            The number of QLineEdits is based on values read from ini-file and processed by some intermediate classes ... too complex to simplify in a hurry

            The editor was created by form-designer of QtCreator and consists of QLabel, QLineEdit and QGridLayout. Taborder was specified in QtCreator too.

            The editor class (only problem related parts):

            #include <dynwidget.h>
            #include <ui_Fixture.h>
            class QLineEdit;
            class AxisMask;
            
            
            class FixtureEdit : public DynWidget // , protected Ui_frame
            {
            public:
              FixtureEdit(const QString& title, const AxisMask& mask, QWidget* parent = nullptr);
            
            protected:
              void setupUi(DynWidget* parent);
            
            private:
              Ui::frame*      ui;
              const AxisMask& m;
              };
            

            constructor ...

            FixtureEdit::FixtureEdit(const QString& title, const AxisMask& mask, QWidget* parent)
             : DynWidget(QString(), parent)
             , ui(new Ui::frame())
             , m(mask) {
              setupUi(this);
              ui->title->setText(title);
              layout()->setContentsMargins(0, 0, 0, 0);
              }
            

            ... and setupUi (lX is a QLabel and edX the QLineEdit):

            void FixtureEdit::setupUi(DynWidget* parent) {
              ui->setupUi(parent);
              ui->lX->setVisible(m.hasXAxis());
              ui->lY->setVisible(m.hasYAxis());
              ui->lZ->setVisible(m.hasZAxis());
              ui->lA->setVisible(m.hasAAxis());
              ui->lB->setVisible(m.hasBAxis());
              ui->lC->setVisible(m.hasCAxis());
              ui->lU->setVisible(m.hasUAxis());
              ui->lV->setVisible(m.hasVAxis());
              ui->lW->setVisible(m.hasWAxis());
              ui->edX->setVisible(m.hasXAxis());
              ui->edY->setVisible(m.hasYAxis());
              ui->edZ->setVisible(m.hasZAxis());
              ui->edA->setVisible(m.hasAAxis());
              ui->edB->setVisible(m.hasBAxis());
              ui->edC->setVisible(m.hasCAxis());
              ui->edU->setVisible(m.hasUAxis());
              ui->edV->setVisible(m.hasVAxis());
              ui->edW->setVisible(m.hasWAxis());
              }
            

            last not least the ui-file:

            <?xml version="1.0" encoding="UTF-8"?>
            <ui version="4.0">
             <class>frame</class>
             <widget class="DynWidget" name="frame">
              <property name="geometry">
               <rect>
                <x>0</x>
                <y>0</y>
                <width>233</width>
                <height>336</height>
               </rect>
              </property>
              <property name="sizePolicy">
               <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
              <property name="lineWidth" stdset="0">
               <number>3</number>
              </property>
              <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0" columnstretch="0,0">
               <property name="leftMargin">
                <number>0</number>
               </property>
               <property name="topMargin">
                <number>0</number>
               </property>
               <property name="rightMargin">
                <number>0</number>
               </property>
               <property name="bottomMargin">
                <number>0</number>
               </property>
               <property name="verticalSpacing">
                <number>1</number>
               </property>
               <item row="5" column="1">
                <widget class="QLineEdit" name="edA">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="7" column="0">
                <widget class="QLabel" name="lC">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>C</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="8" column="1">
                <widget class="QLineEdit" name="edU">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="10" column="1">
                <widget class="QLineEdit" name="edW">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="3" column="0">
                <widget class="QLabel" name="lY">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>Y</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="6" column="1">
                <widget class="QLineEdit" name="edB">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="2" column="1">
                <widget class="QLineEdit" name="edX">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="2" column="0">
                <widget class="QLabel" name="lX">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>X</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="10" column="0">
                <widget class="QLabel" name="lW">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>W</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="4" column="0">
                <widget class="QLabel" name="lZ">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>Z</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="9" column="1">
                <widget class="QLineEdit" name="edV">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="9" column="0">
                <widget class="QLabel" name="lV">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>V</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="8" column="0">
                <widget class="QLabel" name="lU">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>U</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="7" column="1">
                <widget class="QLineEdit" name="edC">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="6" column="0">
                <widget class="QLabel" name="lB">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>B</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="4" column="1">
                <widget class="QLineEdit" name="edZ">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="3" column="1">
                <widget class="QLineEdit" name="edY">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                 </property>
                </widget>
               </item>
               <item row="5" column="0">
                <widget class="QLabel" name="lA">
                 <property name="minimumSize">
                  <size>
                   <width>25</width>
                   <height>0</height>
                  </size>
                 </property>
                 <property name="text">
                  <string>A</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
               <item row="1" column="0" colspan="2">
                <widget class="QLabel" name="title">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
                   <horstretch>0</horstretch>
                   <verstretch>0</verstretch>
                  </sizepolicy>
                 </property>
                 <property name="font">
                  <font>
                   <pointsize>12</pointsize>
                   <weight>75</weight>
                   <bold>true</bold>
                  </font>
                 </property>
                 <property name="frameShape">
                  <enum>QFrame::Panel</enum>
                 </property>
                 <property name="frameShadow">
                  <enum>QFrame::Raised</enum>
                 </property>
                 <property name="text">
                  <string>G54</string>
                 </property>
                 <property name="alignment">
                  <set>Qt::AlignCenter</set>
                 </property>
                </widget>
               </item>
              </layout>
             </widget>
             <customwidgets>
              <customwidget>
               <class>DynWidget</class>
               <extends>QWidget</extends>
               <header>dynwidget.h</header>
               <container>1</container>
              </customwidget>
             </customwidgets>
             <tabstops>
              <tabstop>edX</tabstop>
              <tabstop>edY</tabstop>
              <tabstop>edZ</tabstop>
              <tabstop>edA</tabstop>
              <tabstop>edB</tabstop>
              <tabstop>edC</tabstop>
              <tabstop>edU</tabstop>
              <tabstop>edV</tabstop>
              <tabstop>edW</tabstop>
             </tabstops>
             <resources/>
             <connections/>
            </ui>
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @django-Reinhard said in Invisible QLineEdit receive Focus?!?:

            Sorry, but that would be too much work.

            Way, way too much detail. Nobody (other then you) wants to have to wade through this.

            Reduce to 2 labels on a QGridLayout. Do your setVisible() on each and see what happens to tabbing. If that functions correctly, work back up to your actual situation. If that does not function correctly, show non-functioning code with 2 labels.

            1 Reply Last reply
            0
            • D django.Reinhard

              @JonB said in Invisible QLineEdit receive Focus?!?:

              Do you have just plain QLineEdits on some simple layout ...

              Yes, QLineEdit with QGridLayout ...

              @eyllanesc said in Invisible QLineEdit receive Focus?!?:

              please provide a verifiable example.

              Sorry, but that would be too much work.
              Look:

              Fixture013.jpg

              The App consists of a center widget and several dockables. Center-widget is a stack and here the main widget of the QScrollArea manages 10 Editors in a FlowLayout.
              My goal was to make the application usable without a mouse. This led to some peculiarities that are not known from mouse applications.

              ... any way:
              The number of QLineEdits is based on values read from ini-file and processed by some intermediate classes ... too complex to simplify in a hurry

              The editor was created by form-designer of QtCreator and consists of QLabel, QLineEdit and QGridLayout. Taborder was specified in QtCreator too.

              The editor class (only problem related parts):

              #include <dynwidget.h>
              #include <ui_Fixture.h>
              class QLineEdit;
              class AxisMask;
              
              
              class FixtureEdit : public DynWidget // , protected Ui_frame
              {
              public:
                FixtureEdit(const QString& title, const AxisMask& mask, QWidget* parent = nullptr);
              
              protected:
                void setupUi(DynWidget* parent);
              
              private:
                Ui::frame*      ui;
                const AxisMask& m;
                };
              

              constructor ...

              FixtureEdit::FixtureEdit(const QString& title, const AxisMask& mask, QWidget* parent)
               : DynWidget(QString(), parent)
               , ui(new Ui::frame())
               , m(mask) {
                setupUi(this);
                ui->title->setText(title);
                layout()->setContentsMargins(0, 0, 0, 0);
                }
              

              ... and setupUi (lX is a QLabel and edX the QLineEdit):

              void FixtureEdit::setupUi(DynWidget* parent) {
                ui->setupUi(parent);
                ui->lX->setVisible(m.hasXAxis());
                ui->lY->setVisible(m.hasYAxis());
                ui->lZ->setVisible(m.hasZAxis());
                ui->lA->setVisible(m.hasAAxis());
                ui->lB->setVisible(m.hasBAxis());
                ui->lC->setVisible(m.hasCAxis());
                ui->lU->setVisible(m.hasUAxis());
                ui->lV->setVisible(m.hasVAxis());
                ui->lW->setVisible(m.hasWAxis());
                ui->edX->setVisible(m.hasXAxis());
                ui->edY->setVisible(m.hasYAxis());
                ui->edZ->setVisible(m.hasZAxis());
                ui->edA->setVisible(m.hasAAxis());
                ui->edB->setVisible(m.hasBAxis());
                ui->edC->setVisible(m.hasCAxis());
                ui->edU->setVisible(m.hasUAxis());
                ui->edV->setVisible(m.hasVAxis());
                ui->edW->setVisible(m.hasWAxis());
                }
              

              last not least the ui-file:

              <?xml version="1.0" encoding="UTF-8"?>
              <ui version="4.0">
               <class>frame</class>
               <widget class="DynWidget" name="frame">
                <property name="geometry">
                 <rect>
                  <x>0</x>
                  <y>0</y>
                  <width>233</width>
                  <height>336</height>
                 </rect>
                </property>
                <property name="sizePolicy">
                 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
                  <horstretch>0</horstretch>
                  <verstretch>0</verstretch>
                 </sizepolicy>
                </property>
                <property name="lineWidth" stdset="0">
                 <number>3</number>
                </property>
                <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0" columnstretch="0,0">
                 <property name="leftMargin">
                  <number>0</number>
                 </property>
                 <property name="topMargin">
                  <number>0</number>
                 </property>
                 <property name="rightMargin">
                  <number>0</number>
                 </property>
                 <property name="bottomMargin">
                  <number>0</number>
                 </property>
                 <property name="verticalSpacing">
                  <number>1</number>
                 </property>
                 <item row="5" column="1">
                  <widget class="QLineEdit" name="edA">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="7" column="0">
                  <widget class="QLabel" name="lC">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>C</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="8" column="1">
                  <widget class="QLineEdit" name="edU">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="10" column="1">
                  <widget class="QLineEdit" name="edW">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="3" column="0">
                  <widget class="QLabel" name="lY">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>Y</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="6" column="1">
                  <widget class="QLineEdit" name="edB">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="2" column="1">
                  <widget class="QLineEdit" name="edX">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="2" column="0">
                  <widget class="QLabel" name="lX">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>X</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="10" column="0">
                  <widget class="QLabel" name="lW">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>W</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="4" column="0">
                  <widget class="QLabel" name="lZ">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>Z</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="9" column="1">
                  <widget class="QLineEdit" name="edV">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="9" column="0">
                  <widget class="QLabel" name="lV">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>V</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="8" column="0">
                  <widget class="QLabel" name="lU">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>U</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="7" column="1">
                  <widget class="QLineEdit" name="edC">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="6" column="0">
                  <widget class="QLabel" name="lB">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>B</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="4" column="1">
                  <widget class="QLineEdit" name="edZ">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="3" column="1">
                  <widget class="QLineEdit" name="edY">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="5" column="0">
                  <widget class="QLabel" name="lA">
                   <property name="minimumSize">
                    <size>
                     <width>25</width>
                     <height>0</height>
                    </size>
                   </property>
                   <property name="text">
                    <string>A</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                 <item row="1" column="0" colspan="2">
                  <widget class="QLabel" name="title">
                   <property name="sizePolicy">
                    <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
                     <horstretch>0</horstretch>
                     <verstretch>0</verstretch>
                    </sizepolicy>
                   </property>
                   <property name="font">
                    <font>
                     <pointsize>12</pointsize>
                     <weight>75</weight>
                     <bold>true</bold>
                    </font>
                   </property>
                   <property name="frameShape">
                    <enum>QFrame::Panel</enum>
                   </property>
                   <property name="frameShadow">
                    <enum>QFrame::Raised</enum>
                   </property>
                   <property name="text">
                    <string>G54</string>
                   </property>
                   <property name="alignment">
                    <set>Qt::AlignCenter</set>
                   </property>
                  </widget>
                 </item>
                </layout>
               </widget>
               <customwidgets>
                <customwidget>
                 <class>DynWidget</class>
                 <extends>QWidget</extends>
                 <header>dynwidget.h</header>
                 <container>1</container>
                </customwidget>
               </customwidgets>
               <tabstops>
                <tabstop>edX</tabstop>
                <tabstop>edY</tabstop>
                <tabstop>edZ</tabstop>
                <tabstop>edA</tabstop>
                <tabstop>edB</tabstop>
                <tabstop>edC</tabstop>
                <tabstop>edU</tabstop>
                <tabstop>edV</tabstop>
                <tabstop>edW</tabstop>
               </tabstops>
               <resources/>
               <connections/>
              </ui>
              
              Cobra91151C Offline
              Cobra91151C Offline
              Cobra91151
              wrote on last edited by
              #6

              @django-Reinhard

              Hello!

              You can try to set fields tab order by yourself using the setTabOrder method: https://doc.qt.io/qt-5/qwidget.html#setTabOrder

              For example:

              setTabOrder(ui->edB, ui->edA);
              
              D 1 Reply Last reply
              0
              • Cobra91151C Cobra91151

                @django-Reinhard

                Hello!

                You can try to set fields tab order by yourself using the setTabOrder method: https://doc.qt.io/qt-5/qwidget.html#setTabOrder

                For example:

                setTabOrder(ui->edB, ui->edA);
                
                D Offline
                D Offline
                django.Reinhard
                wrote on last edited by
                #7

                Hi,

                @Cobra91151 said in Invisible QLineEdit receive Focus?!?:

                you can try to set fields tab order by yourself

                Thank you for that hint!

                Ugly, but sounds like a workaround. I'll try that.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  django.Reinhard
                  wrote on last edited by
                  #8

                  Hi,

                  @Cobra91151
                  thanks to your hint usage of the editor is a bit better, but still weird.

                  I use this code:

                    int start = -1, first = 0, second = 1, mx = edits.size() - 1;
                  
                    do {
                       while (first < mx) {
                             if (m.hasAxis(first)) break;
                             ++first;
                             }
                       second = first + 1;
                       while (second < mx) {
                             if (m.hasAxis(second)) break;
                             ++second;
                             }
                       qDebug() << "set taborder" << first << "->" << second;
                       QWidget::setTabOrder(edits.at(first), edits.at(second));
                       if (start < 0) start = first;
                       first = second;
                       } while (first < mx);
                  //  qDebug() << "set taborder" << second << "->" << start;
                  //  QWidget::setTabOrder(edits.at(second), edits.at(start));
                  

                  and debug log reports:

                  set taborder 1 -> 2
                  set taborder 2 -> 3
                  set taborder 3 -> 8
                  

                  Tab-key switches from first to last editfield as expected, but it needs 5 tab-key presses to turn from last to first edit.

                  When I uncomment both last two lines, debug log reports:

                  set taborder 1 -> 2
                  set taborder 2 -> 3
                  set taborder 3 -> 8
                  set taborder 8 -> 1
                  

                  but order of editfields is (in drive letters) X, Z, A, W, Y, +5

                  So in sum still suboptimal.

                  Cobra91151C 1 Reply Last reply
                  0
                  • D django.Reinhard

                    Hi,

                    @Cobra91151
                    thanks to your hint usage of the editor is a bit better, but still weird.

                    I use this code:

                      int start = -1, first = 0, second = 1, mx = edits.size() - 1;
                    
                      do {
                         while (first < mx) {
                               if (m.hasAxis(first)) break;
                               ++first;
                               }
                         second = first + 1;
                         while (second < mx) {
                               if (m.hasAxis(second)) break;
                               ++second;
                               }
                         qDebug() << "set taborder" << first << "->" << second;
                         QWidget::setTabOrder(edits.at(first), edits.at(second));
                         if (start < 0) start = first;
                         first = second;
                         } while (first < mx);
                    //  qDebug() << "set taborder" << second << "->" << start;
                    //  QWidget::setTabOrder(edits.at(second), edits.at(start));
                    

                    and debug log reports:

                    set taborder 1 -> 2
                    set taborder 2 -> 3
                    set taborder 3 -> 8
                    

                    Tab-key switches from first to last editfield as expected, but it needs 5 tab-key presses to turn from last to first edit.

                    When I uncomment both last two lines, debug log reports:

                    set taborder 1 -> 2
                    set taborder 2 -> 3
                    set taborder 3 -> 8
                    set taborder 8 -> 1
                    

                    but order of editfields is (in drive letters) X, Z, A, W, Y, +5

                    So in sum still suboptimal.

                    Cobra91151C Offline
                    Cobra91151C Offline
                    Cobra91151
                    wrote on last edited by
                    #9

                    @django-Reinhard

                    I would suggest to store your edit fields in some container to keep the order, for example: QHash (https://doc.qt.io/qt-5/qhash.html#details).

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      django.Reinhard
                      wrote on last edited by
                      #10

                      Hi,

                      @Cobra91151 said in Invisible QLineEdit receive Focus?!?:

                      I would suggest to store your edit fields in some container

                      They are already in a container (QList) for sequential access.
                      Don't know whether I got you right.
                      Probably it would be better, not using forms by qtcreator but use programmatically created elements.

                      That would be possible, but was not the idea. Just loading another ini-file could lead to completely different field pattern.
                      I have the same usecase on the position-display, but there I don't have user input, so that works without issue.

                      But ok, creating the entire editor on my own would skip the odd behaviour.

                      OK, thank you for the hint!

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        django.Reinhard
                        wrote on last edited by
                        #11

                        Just to close this:
                        I solved the problem with this solution

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved