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. Ui, finding control by using literal string

Ui, finding control by using literal string

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 605 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I have a number of controls on a form, these have been named with an index after each name, e.g. lblT0, lblT1, lblT2 etc.

    The idea is that a bunch of controls do the same thing and have been copied into layouts, the form is resized to show the number of layouts applicable. I need to be able to search for controls using the index of the control to update, how can I do this? I've looked for methods to search for controls, I couldn't see anything.

    Something like:

    • Look for iterator for QString("lblT%1").arg(index)
    • If iterator finds control, update control.

    Kind Regards,
    Sy

    jsulmJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      @jsulm , on my form I have a layout QVBoxLayout it has the name pvtloTrainees, this layout has lots of children, here is the UI:

      <?xml version="1.0" encoding="UTF-8"?>
      <ui version="4.0">
      <class>SendRDF</class>
      <widget class="QMainWindow" name="SendRDF">
        <property name="windowModality">
         <enum>Qt::ApplicationModal</enum>
        </property>
        <property name="geometry">
         <rect>
          <x>0</x>
          <y>0</y>
          <width>620</width>
          <height>681</height>
         </rect>
        </property>
        <property name="minimumSize">
         <size>
          <width>492</width>
          <height>108</height>
         </size>
        </property>
        <property name="styleSheet">
         <string notr="true">QMainWindow{border:2px solid black;}</string>
        </property>
        <widget class="QWidget" name="centralWidget">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
           <horstretch>0</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
         <layout class="QGridLayout" name="gridLayout">
          <item row="0" column="0">
           <widget class="QLabel" name="label">
            <property name="text">
             <string>RDF file:</string>
            </property>
            <property name="alignment">
             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
            </property>
           </widget>
         </item>
          <item row="0" column="1" colspan="3">
           <widget class="QLabel" name="plblFilename">
            <property name="text">
             <string>Device, path and filename</string>
            </property>
           </widget>
          </item>
          <item row="1" column="0">
           <widget class="QLabel" name="label_2">
            <property name="text">
             <string>File size:</string>
            </property>
            <property name="alignment">
             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
            </property>
           </widget>
          </item>
          <item row="1" column="1">
           <widget class="QLabel" name="plblFilesize">
            <property name="contextMenuPolicy">
             <enum>Qt::NoContextMenu</enum>
            </property>
            <property name="text">
             <string>##########</string>
            </property>
            <property name="alignment">
             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
            </property>
           </widget>
          </item>
          <item row="1" column="2" colspan="3">
           <spacer name="horizontalSpacer">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
             </size>
            </property>
           </spacer>
          </item>
          <item row="1" column="5">
           <widget class="QLabel" name="label_5">
            <property name="text">
             <string>Elapsed:</string>
            </property>
           </widget>
          </item>
          <item row="1" column="6">
           <widget class="QLabel" name="plblElapsed">
            <property name="text">
             <string>##:##:##.###</string>
            </property>
           </widget>
          </item>
          <item row="2" column="0" colspan="7">
           <widget class="QGroupBox" name="pgrpTrainees">
            <property name="sizePolicy">
             <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
              <horstretch>1</horstretch>
              <verstretch>1</verstretch>
             </sizepolicy>
            </property>
            <property name="title">
             <string/>
            </property>
            <property name="flat">
             <bool>true</bool>
            </property>
            <widget class="QWidget" name="verticalLayoutWidget">
             <property name="geometry">
              <rect>
               <x>0</x>
               <y>0</y>
               <width>600</width>
               <height>585</height>
              </rect>
             </property>
             <layout class="QVBoxLayout" name="pvtloTrainees">
              <item>
               <layout class="QVBoxLayout" name="pvbloT0">
                <item>
                 <layout class="QHBoxLayout" name="phzloT0">
                  <item>
                   <widget class="QLabel" name="plblT0">
                    <property name="enabled">
                     <bool>true</bool>
                    </property>
                    <property name="sizePolicy">
                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
                    <property name="styleSheet">
                     <string notr="true"/>
                    </property>
                    <property name="text">
                     <string>Trainee:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTN0">
                    <property name="text">
                     <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <spacer name="sprT0">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTBlocks0">
                    <property name="text">
                     <string>Blocks:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTB0">
                    <property name="text">
                     <string>#######</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                 </layout>
                </item>
                <item>
                 <widget class="QLabel" name="plblTE0">
                  <property name="sizePolicy">
                   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                    <horstretch>0</horstretch>
                    <verstretch>0</verstretch>
                   </sizepolicy>
                  </property>
                  <property name="layoutDirection">
                   <enum>Qt::LeftToRight</enum>
                  </property>
                  <property name="styleSheet">
                   <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                  </property>
                  <property name="text">
                   <string/>
                  </property>
                  <property name="textFormat">
                   <enum>Qt::AutoText</enum>
                  </property>
                  <property name="alignment">
                   <set>Qt::AlignCenter</set>
                  </property>
                 </widget>
                </item>
                <item>
                 <widget class="QProgressBar" name="ppgbT0">
                  <property name="value">
                   <number>0</number>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
              <item>
               <layout class="QVBoxLayout" name="pvbloT1">
                <item>
                 <layout class="QHBoxLayout" name="phzloT1">
                  <item>
                   <widget class="QLabel" name="plblT1">
                    <property name="enabled">
                     <bool>true</bool>
                    </property>
                    <property name="sizePolicy">
                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
                    <property name="styleSheet">
                     <string notr="true"/>
                    </property>
                    <property name="text">
                     <string>Trainee:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTN1">
                    <property name="text">
                     <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <spacer name="sprT1">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTBlocks1">
                    <property name="text">
                     <string>Blocks:</string>
                   </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTB1">
                    <property name="text">
                     <string>#######</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                 </layout>
                </item>
                <item>
                 <widget class="QLabel" name="plblTE1">
                  <property name="sizePolicy">
                   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                    <horstretch>0</horstretch>
                    <verstretch>0</verstretch>
                   </sizepolicy>
                  </property>
                  <property name="layoutDirection">
                   <enum>Qt::LeftToRight</enum>
                  </property>
                  <property name="styleSheet">
                   <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                  </property>
                  <property name="text">
                   <string/>
                  </property>
                  <property name="textFormat">
                   <enum>Qt::AutoText</enum>
                  </property>
                  <property name="alignment">
                   <set>Qt::AlignCenter</set>
                  </property>
                 </widget>
                </item>
                <item>
                 <widget class="QProgressBar" name="ppgbT1">
                  <property name="value">
                   <number>0</number>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
              <item>
              <layout class="QVBoxLayout" name="pvbloT2">
                <item>
                 <layout class="QHBoxLayout" name="phzloT2">
                  <item>
                   <widget class="QLabel" name="plblT2">
                    <property name="enabled">
                     <bool>true</bool>
                    </property>
                    <property name="sizePolicy">
                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
                    <property name="styleSheet">
                     <string notr="true"/>
                    </property>
                    <property name="text">
                     <string>Trainee:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTN2">
                    <property name="text">
                     <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <spacer name="sprT2">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTBlocks2">
                    <property name="text">
                     <string>Blocks:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTB2">
                    <property name="text">
                     <string>#######</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                 </layout>
                </item>
                <item>
                 <widget class="QLabel" name="plblTE2">
                  <property name="sizePolicy">
                   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                    <horstretch>0</horstretch>
                    <verstretch>0</verstretch>
                   </sizepolicy>
                  </property>
                  <property name="layoutDirection">
                   <enum>Qt::LeftToRight</enum>
                  </property>
                  <property name="styleSheet">
                   <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                  </property>
                  <property name="text">
                   <string/>
                  </property>
                  <property name="textFormat">
                   <enum>Qt::AutoText</enum>
                  </property>
                  <property name="alignment">
                   <set>Qt::AlignCenter</set>
                  </property>
                 </widget>
                </item>
                <item>
                 <widget class="QProgressBar" name="ppgbT2">
                  <property name="value">
                   <number>0</number>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
              <item>
               <layout class="QVBoxLayout" name="pvbloT3">
                <item>
                 <layout class="QHBoxLayout" name="phzloT3">
                  <item>
                   <widget class="QLabel" name="plblT3">
                    <property name="enabled">
                     <bool>true</bool>
                    </property>
                    <property name="sizePolicy">
                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
                    <property name="styleSheet">
                     <string notr="true"/>
                    </property>
                    <property name="text">
                     <string>Trainee:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTN3">
                    <property name="text">
                     <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <spacer name="sprT3">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTBlocks3">
                    <property name="text">
                     <string>Blocks:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTB3">
                    <property name="text">
                     <string>#######</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                 </layout>
                </item>
                <item>
                 <widget class="QProgressBar" name="ppgbT3">
                  <property name="value">
                   <number>0</number>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
              <item>
               <layout class="QVBoxLayout" name="pvbloT4">
                <item>
                 <layout class="QHBoxLayout" name="phzloT4">
                  <item>
                   <widget class="QLabel" name="plblT4">
                    <property name="enabled">
                     <bool>true</bool>
                    </property>
                    <property name="sizePolicy">
                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
                    <property name="styleSheet">
                     <string notr="true"/>
                    </property>
                    <property name="text">
                     <string>Trainee:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTN4">
                    <property name="text">
                     <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <spacer name="sprT4">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTBlocks4">
                    <property name="text">
                     <string>Blocks:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTB4">
                    <property name="text">
                     <string>#######</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                 </layout>
                </item>
                <item>
                 <widget class="QLabel" name="plblTE4">
                  <property name="sizePolicy">
                   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                    <horstretch>0</horstretch>
                    <verstretch>0</verstretch>
                   </sizepolicy>
                  </property>
                  <property name="layoutDirection">
                   <enum>Qt::LeftToRight</enum>
                  </property>
                  <property name="styleSheet">
                   <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                  </property>
                  <property name="text">
                   <string/>
                  </property>
                  <property name="textFormat">
                   <enum>Qt::AutoText</enum>
                  </property>
                  <property name="alignment">
                   <set>Qt::AlignCenter</set>
                  </property>
                 </widget>
                </item>
                <item>
                 <widget class="QProgressBar" name="ppgbT4">
                  <property name="value">
                   <number>0</number>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
              <item>
               <layout class="QVBoxLayout" name="pvbloT5">
                <item>
                 <layout class="QHBoxLayout" name="phzloT5">
                  <item>
                   <widget class="QLabel" name="plblT5">
                    <property name="enabled">
                     <bool>true</bool>
                    </property>
                   <property name="sizePolicy">
                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
                   <property name="styleSheet">
                     <string notr="true"/>
                    </property>
                    <property name="text">
                     <string>Trainee:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTN5">
                    <property name="text">
                     <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <spacer name="sprT5">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTBlocks5">
                    <property name="text">
                     <string>Blocks:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTB5">
                    <property name="text">
                     <string>#######</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                 </layout>
                </item>
                <item>
                 <widget class="QLabel" name="plblTE5">
                  <property name="sizePolicy">
                   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                    <horstretch>0</horstretch>
                    <verstretch>0</verstretch>
                   </sizepolicy>
                  </property>
                  <property name="layoutDirection">
                   <enum>Qt::LeftToRight</enum>
                  </property>
                  <property name="styleSheet">
                   <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                  </property>
                  <property name="text">
                   <string/>
                  </property>
                  <property name="textFormat">
                   <enum>Qt::AutoText</enum>
                  </property>
                  <property name="alignment">
                   <set>Qt::AlignCenter</set>
                  </property>
                 </widget>
                </item>
                <item>
                 <widget class="QProgressBar" name="ppgbT5">
                  <property name="value">
                   <number>0</number>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
              <item>
               <layout class="QVBoxLayout" name="pvbloT6">
                <item>
                 <layout class="QHBoxLayout" name="phzloT6">
                  <item>
                   <widget class="QLabel" name="plblT6">
                    <property name="enabled">
                     <bool>true</bool>
                    </property>
                    <property name="sizePolicy">
                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
                    <property name="styleSheet">
                     <string notr="true"/>
                    </property>
                    <property name="text">
                     <string>Trainee:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTN6">
                    <property name="text">
                     <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <spacer name="sprT6">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTBlocks6">
                    <property name="text">
                     <string>Blocks:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTB6">
                    <property name="text">
                     <string>#######</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                 </layout>
                </item>
                <item>
                 <widget class="QLabel" name="plblTE6">
                  <property name="sizePolicy">
                   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                    <horstretch>0</horstretch>
                    <verstretch>0</verstretch>
                   </sizepolicy>
                  </property>
                  <property name="layoutDirection">
                   <enum>Qt::LeftToRight</enum>
                  </property>
                  <property name="styleSheet">
                   <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                  </property>
                  <property name="text">
                   <string/>
                  </property>
                  <property name="textFormat">
                   <enum>Qt::AutoText</enum>
                  </property>
                  <property name="alignment">
                   <set>Qt::AlignCenter</set>
                  </property>
                 </widget>
                </item>
                <item>
                 <widget class="QProgressBar" name="ppgbT6">
                  <property name="value">
                   <number>0</number>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
              <item>
               <layout class="QVBoxLayout" name="pvbloT7">
                <item>
                 <layout class="QHBoxLayout" name="phzloT7">
                  <item>
                   <widget class="QLabel" name="plblT7">
                    <property name="enabled">
                     <bool>true</bool>
                    </property>
                    <property name="sizePolicy">
                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                     <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
                    <property name="styleSheet">
                     <string notr="true"/>
                    </property>
                    <property name="text">
                     <string>Trainee:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTN7">
                    <property name="text">
                     <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <spacer name="sprT7">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTBlocks7">
                    <property name="text">
                     <string>Blocks:</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                  <item>
                   <widget class="QLabel" name="plblTB7">
                    <property name="text">
                     <string>#######</string>
                    </property>
                    <property name="alignment">
                     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                    </property>
                   </widget>
                  </item>
                 </layout>
                </item>
                <item>
                 <widget class="QLabel" name="plblTE7">
                  <property name="sizePolicy">
                   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                    <horstretch>0</horstretch>
                    <verstretch>0</verstretch>
                   </sizepolicy>
                  </property>
                  <property name="layoutDirection">
                  <enum>Qt::LeftToRight</enum>
                  </property>
                  <property name="styleSheet">
                   <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                  </property>
                  <property name="text">
                   <string/>
                  </property>
                  <property name="textFormat">
                   <enum>Qt::AutoText</enum>
                  </property>
                  <property name="alignment">
                   <set>Qt::AlignCenter</set>
                  </property>
                 </widget>
                </item>
                <item>
                 <widget class="QProgressBar" name="ppgbT7">
                  <property name="value">
                   <number>0</number>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
             </layout>
            </widget>
           </widget>
          </item>
          <item row="4" column="6">
           <widget class="QPushButton" name="pbtnAbort">
            <property name="minimumSize">
             <size>
              <width>80</width>
              <height>24</height>
             </size>
            </property>
            <property name="text">
             <string>&amp;Abort</string>
            </property>
           </widget>
          </item>
         </layout>
        </widget>
      </widget>
      <resources/>
      <connections/>
      </ui>
      

      I am trying to locate a widget that is a child of this layout with:

      QWidget* pobjFound(mpui->pvtloTrainees->findChild<QWidget*>(cstrCtrlKey));
      

      Where cstrCtrlKey is a string containing something like ppgbT0, but pobjFound is returned as 0x0 ?

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #11

      @SPlatten as stated beforehand

      Layout cannot be parent of a widget...

      use <widget class="QWidget" name="verticalLayoutWidget">instead.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      SPlattenS 1 Reply Last reply
      0
      • SPlattenS SPlatten

        I have a number of controls on a form, these have been named with an index after each name, e.g. lblT0, lblT1, lblT2 etc.

        The idea is that a bunch of controls do the same thing and have been copied into layouts, the form is resized to show the number of layouts applicable. I need to be able to search for controls using the index of the control to update, how can I do this? I've looked for methods to search for controls, I couldn't see anything.

        Something like:

        • Look for iterator for QString("lblT%1").arg(index)
        • If iterator finds control, update control.
        jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @SPlatten said in Ui, finding control by using literal string:

        these have been named with an index after each name, e.g. lblT0, lblT1, lblT2 etc.

        Do you mean variable names or objectName?
        https://doc.qt.io/qt-5/qobject.html#findChildren

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        SPlattenS 1 Reply Last reply
        0
        • jsulmJ jsulm

          @SPlatten said in Ui, finding control by using literal string:

          these have been named with an index after each name, e.g. lblT0, lblT1, lblT2 etc.

          Do you mean variable names or objectName?
          https://doc.qt.io/qt-5/qobject.html#findChildren

          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #3

          @jsulm , I want to address by objectName, so for example, something like:

          QProgressBar* pBar(ui->find("name"));
          pBar->setValue(123);
          

          Kind Regards,
          Sy

          jsulmJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @jsulm , I want to address by objectName, so for example, something like:

            QProgressBar* pBar(ui->find("name"));
            pBar->setValue(123);
            
            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @SPlatten Isn't https://doc.qt.io/qt-5/qobject.html#findChildren what you need?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            SPlattenS 1 Reply Last reply
            1
            • jsulmJ jsulm

              @SPlatten Isn't https://doc.qt.io/qt-5/qobject.html#findChildren what you need?

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #5

              @jsulm , thank you, if I have the ui pointer how do I use this with findChildren ?

              Kind Regards,
              Sy

              jsulmJ 1 Reply Last reply
              0
              • J.HilkJ Online
                J.HilkJ Online
                J.Hilk
                Moderators
                wrote on last edited by
                #6

                just an annotation, if you call findChildren on your root element of your Ui it will be a very slow function call, as it recursively goes through all the children!

                Either accept that, narrow the search down, by wisely selection the QObject to search on or, what I prefer, store the objects in a member list/vector/array


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                1
                • SPlattenS SPlatten

                  @jsulm , thank you, if I have the ui pointer how do I use this with findChildren ?

                  jsulmJ Online
                  jsulmJ Online
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #7

                  @SPlatten You pass the pointer to the parent widget which contains the widgets you want to search...

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  SPlattenS 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @SPlatten You pass the pointer to the parent widget which contains the widgets you want to search...

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by SPlatten
                    #8

                    @jsulm , I have a layout that contains all the controls, can I use that to speed up the search?

                    @J-Hilk , @jsulm , thank you, have added:

                    ui->pvtloTrainees->findChild("...");
                    

                    Kind Regards,
                    Sy

                    jsulmJ 1 Reply Last reply
                    0
                    • SPlattenS SPlatten

                      @jsulm , I have a layout that contains all the controls, can I use that to speed up the search?

                      @J-Hilk , @jsulm , thank you, have added:

                      ui->pvtloTrainees->findChild("...");
                      
                      jsulmJ Online
                      jsulmJ Online
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by jsulm
                      #9

                      @SPlatten Layout cannot be parent of a widget...
                      Simply use the widget containing this layout and the child widgets...

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      SPlattenS 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @SPlatten Layout cannot be parent of a widget...
                        Simply use the widget containing this layout and the child widgets...

                        SPlattenS Offline
                        SPlattenS Offline
                        SPlatten
                        wrote on last edited by
                        #10

                        @jsulm , on my form I have a layout QVBoxLayout it has the name pvtloTrainees, this layout has lots of children, here is the UI:

                        <?xml version="1.0" encoding="UTF-8"?>
                        <ui version="4.0">
                        <class>SendRDF</class>
                        <widget class="QMainWindow" name="SendRDF">
                          <property name="windowModality">
                           <enum>Qt::ApplicationModal</enum>
                          </property>
                          <property name="geometry">
                           <rect>
                            <x>0</x>
                            <y>0</y>
                            <width>620</width>
                            <height>681</height>
                           </rect>
                          </property>
                          <property name="minimumSize">
                           <size>
                            <width>492</width>
                            <height>108</height>
                           </size>
                          </property>
                          <property name="styleSheet">
                           <string notr="true">QMainWindow{border:2px solid black;}</string>
                          </property>
                          <widget class="QWidget" name="centralWidget">
                           <property name="sizePolicy">
                            <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
                             <horstretch>0</horstretch>
                             <verstretch>0</verstretch>
                            </sizepolicy>
                           </property>
                           <layout class="QGridLayout" name="gridLayout">
                            <item row="0" column="0">
                             <widget class="QLabel" name="label">
                              <property name="text">
                               <string>RDF file:</string>
                              </property>
                              <property name="alignment">
                               <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                              </property>
                             </widget>
                           </item>
                            <item row="0" column="1" colspan="3">
                             <widget class="QLabel" name="plblFilename">
                              <property name="text">
                               <string>Device, path and filename</string>
                              </property>
                             </widget>
                            </item>
                            <item row="1" column="0">
                             <widget class="QLabel" name="label_2">
                              <property name="text">
                               <string>File size:</string>
                              </property>
                              <property name="alignment">
                               <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                              </property>
                             </widget>
                            </item>
                            <item row="1" column="1">
                             <widget class="QLabel" name="plblFilesize">
                              <property name="contextMenuPolicy">
                               <enum>Qt::NoContextMenu</enum>
                              </property>
                              <property name="text">
                               <string>##########</string>
                              </property>
                              <property name="alignment">
                               <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                              </property>
                             </widget>
                            </item>
                            <item row="1" column="2" colspan="3">
                             <spacer name="horizontalSpacer">
                              <property name="orientation">
                               <enum>Qt::Horizontal</enum>
                              </property>
                              <property name="sizeHint" stdset="0">
                               <size>
                                <width>40</width>
                                <height>20</height>
                               </size>
                              </property>
                             </spacer>
                            </item>
                            <item row="1" column="5">
                             <widget class="QLabel" name="label_5">
                              <property name="text">
                               <string>Elapsed:</string>
                              </property>
                             </widget>
                            </item>
                            <item row="1" column="6">
                             <widget class="QLabel" name="plblElapsed">
                              <property name="text">
                               <string>##:##:##.###</string>
                              </property>
                             </widget>
                            </item>
                            <item row="2" column="0" colspan="7">
                             <widget class="QGroupBox" name="pgrpTrainees">
                              <property name="sizePolicy">
                               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                <horstretch>1</horstretch>
                                <verstretch>1</verstretch>
                               </sizepolicy>
                              </property>
                              <property name="title">
                               <string/>
                              </property>
                              <property name="flat">
                               <bool>true</bool>
                              </property>
                              <widget class="QWidget" name="verticalLayoutWidget">
                               <property name="geometry">
                                <rect>
                                 <x>0</x>
                                 <y>0</y>
                                 <width>600</width>
                                 <height>585</height>
                                </rect>
                               </property>
                               <layout class="QVBoxLayout" name="pvtloTrainees">
                                <item>
                                 <layout class="QVBoxLayout" name="pvbloT0">
                                  <item>
                                   <layout class="QHBoxLayout" name="phzloT0">
                                    <item>
                                     <widget class="QLabel" name="plblT0">
                                      <property name="enabled">
                                       <bool>true</bool>
                                      </property>
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true"/>
                                      </property>
                                      <property name="text">
                                       <string>Trainee:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTN0">
                                      <property name="text">
                                       <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <spacer name="sprT0">
                                      <property name="orientation">
                                       <enum>Qt::Horizontal</enum>
                                      </property>
                                      <property name="sizeHint" stdset="0">
                                       <size>
                                        <width>40</width>
                                        <height>20</height>
                                       </size>
                                      </property>
                                     </spacer>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTBlocks0">
                                      <property name="text">
                                       <string>Blocks:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTB0">
                                      <property name="text">
                                       <string>#######</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <widget class="QLabel" name="plblTE0">
                                    <property name="sizePolicy">
                                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                      <horstretch>0</horstretch>
                                      <verstretch>0</verstretch>
                                     </sizepolicy>
                                    </property>
                                    <property name="layoutDirection">
                                     <enum>Qt::LeftToRight</enum>
                                    </property>
                                    <property name="styleSheet">
                                     <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                    </property>
                                    <property name="text">
                                     <string/>
                                    </property>
                                    <property name="textFormat">
                                     <enum>Qt::AutoText</enum>
                                    </property>
                                    <property name="alignment">
                                     <set>Qt::AlignCenter</set>
                                    </property>
                                   </widget>
                                  </item>
                                  <item>
                                   <widget class="QProgressBar" name="ppgbT0">
                                    <property name="value">
                                     <number>0</number>
                                    </property>
                                   </widget>
                                  </item>
                                 </layout>
                                </item>
                                <item>
                                 <layout class="QVBoxLayout" name="pvbloT1">
                                  <item>
                                   <layout class="QHBoxLayout" name="phzloT1">
                                    <item>
                                     <widget class="QLabel" name="plblT1">
                                      <property name="enabled">
                                       <bool>true</bool>
                                      </property>
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true"/>
                                      </property>
                                      <property name="text">
                                       <string>Trainee:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTN1">
                                      <property name="text">
                                       <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <spacer name="sprT1">
                                      <property name="orientation">
                                       <enum>Qt::Horizontal</enum>
                                      </property>
                                      <property name="sizeHint" stdset="0">
                                       <size>
                                        <width>40</width>
                                        <height>20</height>
                                       </size>
                                      </property>
                                     </spacer>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTBlocks1">
                                      <property name="text">
                                       <string>Blocks:</string>
                                     </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTB1">
                                      <property name="text">
                                       <string>#######</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <widget class="QLabel" name="plblTE1">
                                    <property name="sizePolicy">
                                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                      <horstretch>0</horstretch>
                                      <verstretch>0</verstretch>
                                     </sizepolicy>
                                    </property>
                                    <property name="layoutDirection">
                                     <enum>Qt::LeftToRight</enum>
                                    </property>
                                    <property name="styleSheet">
                                     <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                    </property>
                                    <property name="text">
                                     <string/>
                                    </property>
                                    <property name="textFormat">
                                     <enum>Qt::AutoText</enum>
                                    </property>
                                    <property name="alignment">
                                     <set>Qt::AlignCenter</set>
                                    </property>
                                   </widget>
                                  </item>
                                  <item>
                                   <widget class="QProgressBar" name="ppgbT1">
                                    <property name="value">
                                     <number>0</number>
                                    </property>
                                   </widget>
                                  </item>
                                 </layout>
                                </item>
                                <item>
                                <layout class="QVBoxLayout" name="pvbloT2">
                                  <item>
                                   <layout class="QHBoxLayout" name="phzloT2">
                                    <item>
                                     <widget class="QLabel" name="plblT2">
                                      <property name="enabled">
                                       <bool>true</bool>
                                      </property>
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true"/>
                                      </property>
                                      <property name="text">
                                       <string>Trainee:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTN2">
                                      <property name="text">
                                       <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <spacer name="sprT2">
                                      <property name="orientation">
                                       <enum>Qt::Horizontal</enum>
                                      </property>
                                      <property name="sizeHint" stdset="0">
                                       <size>
                                        <width>40</width>
                                        <height>20</height>
                                       </size>
                                      </property>
                                     </spacer>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTBlocks2">
                                      <property name="text">
                                       <string>Blocks:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTB2">
                                      <property name="text">
                                       <string>#######</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <widget class="QLabel" name="plblTE2">
                                    <property name="sizePolicy">
                                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                      <horstretch>0</horstretch>
                                      <verstretch>0</verstretch>
                                     </sizepolicy>
                                    </property>
                                    <property name="layoutDirection">
                                     <enum>Qt::LeftToRight</enum>
                                    </property>
                                    <property name="styleSheet">
                                     <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                    </property>
                                    <property name="text">
                                     <string/>
                                    </property>
                                    <property name="textFormat">
                                     <enum>Qt::AutoText</enum>
                                    </property>
                                    <property name="alignment">
                                     <set>Qt::AlignCenter</set>
                                    </property>
                                   </widget>
                                  </item>
                                  <item>
                                   <widget class="QProgressBar" name="ppgbT2">
                                    <property name="value">
                                     <number>0</number>
                                    </property>
                                   </widget>
                                  </item>
                                 </layout>
                                </item>
                                <item>
                                 <layout class="QVBoxLayout" name="pvbloT3">
                                  <item>
                                   <layout class="QHBoxLayout" name="phzloT3">
                                    <item>
                                     <widget class="QLabel" name="plblT3">
                                      <property name="enabled">
                                       <bool>true</bool>
                                      </property>
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true"/>
                                      </property>
                                      <property name="text">
                                       <string>Trainee:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTN3">
                                      <property name="text">
                                       <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <spacer name="sprT3">
                                      <property name="orientation">
                                       <enum>Qt::Horizontal</enum>
                                      </property>
                                      <property name="sizeHint" stdset="0">
                                       <size>
                                        <width>40</width>
                                        <height>20</height>
                                       </size>
                                      </property>
                                     </spacer>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTBlocks3">
                                      <property name="text">
                                       <string>Blocks:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTB3">
                                      <property name="text">
                                       <string>#######</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <widget class="QProgressBar" name="ppgbT3">
                                    <property name="value">
                                     <number>0</number>
                                    </property>
                                   </widget>
                                  </item>
                                 </layout>
                                </item>
                                <item>
                                 <layout class="QVBoxLayout" name="pvbloT4">
                                  <item>
                                   <layout class="QHBoxLayout" name="phzloT4">
                                    <item>
                                     <widget class="QLabel" name="plblT4">
                                      <property name="enabled">
                                       <bool>true</bool>
                                      </property>
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true"/>
                                      </property>
                                      <property name="text">
                                       <string>Trainee:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTN4">
                                      <property name="text">
                                       <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <spacer name="sprT4">
                                      <property name="orientation">
                                       <enum>Qt::Horizontal</enum>
                                      </property>
                                      <property name="sizeHint" stdset="0">
                                       <size>
                                        <width>40</width>
                                        <height>20</height>
                                       </size>
                                      </property>
                                     </spacer>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTBlocks4">
                                      <property name="text">
                                       <string>Blocks:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTB4">
                                      <property name="text">
                                       <string>#######</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <widget class="QLabel" name="plblTE4">
                                    <property name="sizePolicy">
                                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                      <horstretch>0</horstretch>
                                      <verstretch>0</verstretch>
                                     </sizepolicy>
                                    </property>
                                    <property name="layoutDirection">
                                     <enum>Qt::LeftToRight</enum>
                                    </property>
                                    <property name="styleSheet">
                                     <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                    </property>
                                    <property name="text">
                                     <string/>
                                    </property>
                                    <property name="textFormat">
                                     <enum>Qt::AutoText</enum>
                                    </property>
                                    <property name="alignment">
                                     <set>Qt::AlignCenter</set>
                                    </property>
                                   </widget>
                                  </item>
                                  <item>
                                   <widget class="QProgressBar" name="ppgbT4">
                                    <property name="value">
                                     <number>0</number>
                                    </property>
                                   </widget>
                                  </item>
                                 </layout>
                                </item>
                                <item>
                                 <layout class="QVBoxLayout" name="pvbloT5">
                                  <item>
                                   <layout class="QHBoxLayout" name="phzloT5">
                                    <item>
                                     <widget class="QLabel" name="plblT5">
                                      <property name="enabled">
                                       <bool>true</bool>
                                      </property>
                                     <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                     <property name="styleSheet">
                                       <string notr="true"/>
                                      </property>
                                      <property name="text">
                                       <string>Trainee:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTN5">
                                      <property name="text">
                                       <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <spacer name="sprT5">
                                      <property name="orientation">
                                       <enum>Qt::Horizontal</enum>
                                      </property>
                                      <property name="sizeHint" stdset="0">
                                       <size>
                                        <width>40</width>
                                        <height>20</height>
                                       </size>
                                      </property>
                                     </spacer>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTBlocks5">
                                      <property name="text">
                                       <string>Blocks:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTB5">
                                      <property name="text">
                                       <string>#######</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <widget class="QLabel" name="plblTE5">
                                    <property name="sizePolicy">
                                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                      <horstretch>0</horstretch>
                                      <verstretch>0</verstretch>
                                     </sizepolicy>
                                    </property>
                                    <property name="layoutDirection">
                                     <enum>Qt::LeftToRight</enum>
                                    </property>
                                    <property name="styleSheet">
                                     <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                    </property>
                                    <property name="text">
                                     <string/>
                                    </property>
                                    <property name="textFormat">
                                     <enum>Qt::AutoText</enum>
                                    </property>
                                    <property name="alignment">
                                     <set>Qt::AlignCenter</set>
                                    </property>
                                   </widget>
                                  </item>
                                  <item>
                                   <widget class="QProgressBar" name="ppgbT5">
                                    <property name="value">
                                     <number>0</number>
                                    </property>
                                   </widget>
                                  </item>
                                 </layout>
                                </item>
                                <item>
                                 <layout class="QVBoxLayout" name="pvbloT6">
                                  <item>
                                   <layout class="QHBoxLayout" name="phzloT6">
                                    <item>
                                     <widget class="QLabel" name="plblT6">
                                      <property name="enabled">
                                       <bool>true</bool>
                                      </property>
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true"/>
                                      </property>
                                      <property name="text">
                                       <string>Trainee:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTN6">
                                      <property name="text">
                                       <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <spacer name="sprT6">
                                      <property name="orientation">
                                       <enum>Qt::Horizontal</enum>
                                      </property>
                                      <property name="sizeHint" stdset="0">
                                       <size>
                                        <width>40</width>
                                        <height>20</height>
                                       </size>
                                      </property>
                                     </spacer>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTBlocks6">
                                      <property name="text">
                                       <string>Blocks:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTB6">
                                      <property name="text">
                                       <string>#######</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <widget class="QLabel" name="plblTE6">
                                    <property name="sizePolicy">
                                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                      <horstretch>0</horstretch>
                                      <verstretch>0</verstretch>
                                     </sizepolicy>
                                    </property>
                                    <property name="layoutDirection">
                                     <enum>Qt::LeftToRight</enum>
                                    </property>
                                    <property name="styleSheet">
                                     <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                    </property>
                                    <property name="text">
                                     <string/>
                                    </property>
                                    <property name="textFormat">
                                     <enum>Qt::AutoText</enum>
                                    </property>
                                    <property name="alignment">
                                     <set>Qt::AlignCenter</set>
                                    </property>
                                   </widget>
                                  </item>
                                  <item>
                                   <widget class="QProgressBar" name="ppgbT6">
                                    <property name="value">
                                     <number>0</number>
                                    </property>
                                   </widget>
                                  </item>
                                 </layout>
                                </item>
                                <item>
                                 <layout class="QVBoxLayout" name="pvbloT7">
                                  <item>
                                   <layout class="QHBoxLayout" name="phzloT7">
                                    <item>
                                     <widget class="QLabel" name="plblT7">
                                      <property name="enabled">
                                       <bool>true</bool>
                                      </property>
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                       <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true"/>
                                      </property>
                                      <property name="text">
                                       <string>Trainee:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTN7">
                                      <property name="text">
                                       <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <spacer name="sprT7">
                                      <property name="orientation">
                                       <enum>Qt::Horizontal</enum>
                                      </property>
                                      <property name="sizeHint" stdset="0">
                                       <size>
                                        <width>40</width>
                                        <height>20</height>
                                       </size>
                                      </property>
                                     </spacer>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTBlocks7">
                                      <property name="text">
                                       <string>Blocks:</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTB7">
                                      <property name="text">
                                       <string>#######</string>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <widget class="QLabel" name="plblTE7">
                                    <property name="sizePolicy">
                                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                      <horstretch>0</horstretch>
                                      <verstretch>0</verstretch>
                                     </sizepolicy>
                                    </property>
                                    <property name="layoutDirection">
                                    <enum>Qt::LeftToRight</enum>
                                    </property>
                                    <property name="styleSheet">
                                     <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                    </property>
                                    <property name="text">
                                     <string/>
                                    </property>
                                    <property name="textFormat">
                                     <enum>Qt::AutoText</enum>
                                    </property>
                                    <property name="alignment">
                                     <set>Qt::AlignCenter</set>
                                    </property>
                                   </widget>
                                  </item>
                                  <item>
                                   <widget class="QProgressBar" name="ppgbT7">
                                    <property name="value">
                                     <number>0</number>
                                    </property>
                                   </widget>
                                  </item>
                                 </layout>
                                </item>
                               </layout>
                              </widget>
                             </widget>
                            </item>
                            <item row="4" column="6">
                             <widget class="QPushButton" name="pbtnAbort">
                              <property name="minimumSize">
                               <size>
                                <width>80</width>
                                <height>24</height>
                               </size>
                              </property>
                              <property name="text">
                               <string>&amp;Abort</string>
                              </property>
                             </widget>
                            </item>
                           </layout>
                          </widget>
                        </widget>
                        <resources/>
                        <connections/>
                        </ui>
                        

                        I am trying to locate a widget that is a child of this layout with:

                        QWidget* pobjFound(mpui->pvtloTrainees->findChild<QWidget*>(cstrCtrlKey));
                        

                        Where cstrCtrlKey is a string containing something like ppgbT0, but pobjFound is returned as 0x0 ?

                        Kind Regards,
                        Sy

                        J.HilkJ 1 Reply Last reply
                        0
                        • SPlattenS SPlatten

                          @jsulm , on my form I have a layout QVBoxLayout it has the name pvtloTrainees, this layout has lots of children, here is the UI:

                          <?xml version="1.0" encoding="UTF-8"?>
                          <ui version="4.0">
                          <class>SendRDF</class>
                          <widget class="QMainWindow" name="SendRDF">
                            <property name="windowModality">
                             <enum>Qt::ApplicationModal</enum>
                            </property>
                            <property name="geometry">
                             <rect>
                              <x>0</x>
                              <y>0</y>
                              <width>620</width>
                              <height>681</height>
                             </rect>
                            </property>
                            <property name="minimumSize">
                             <size>
                              <width>492</width>
                              <height>108</height>
                             </size>
                            </property>
                            <property name="styleSheet">
                             <string notr="true">QMainWindow{border:2px solid black;}</string>
                            </property>
                            <widget class="QWidget" name="centralWidget">
                             <property name="sizePolicy">
                              <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
                               <horstretch>0</horstretch>
                               <verstretch>0</verstretch>
                              </sizepolicy>
                             </property>
                             <layout class="QGridLayout" name="gridLayout">
                              <item row="0" column="0">
                               <widget class="QLabel" name="label">
                                <property name="text">
                                 <string>RDF file:</string>
                                </property>
                                <property name="alignment">
                                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                </property>
                               </widget>
                             </item>
                              <item row="0" column="1" colspan="3">
                               <widget class="QLabel" name="plblFilename">
                                <property name="text">
                                 <string>Device, path and filename</string>
                                </property>
                               </widget>
                              </item>
                              <item row="1" column="0">
                               <widget class="QLabel" name="label_2">
                                <property name="text">
                                 <string>File size:</string>
                                </property>
                                <property name="alignment">
                                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                </property>
                               </widget>
                              </item>
                              <item row="1" column="1">
                               <widget class="QLabel" name="plblFilesize">
                                <property name="contextMenuPolicy">
                                 <enum>Qt::NoContextMenu</enum>
                                </property>
                                <property name="text">
                                 <string>##########</string>
                                </property>
                                <property name="alignment">
                                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                </property>
                               </widget>
                              </item>
                              <item row="1" column="2" colspan="3">
                               <spacer name="horizontalSpacer">
                                <property name="orientation">
                                 <enum>Qt::Horizontal</enum>
                                </property>
                                <property name="sizeHint" stdset="0">
                                 <size>
                                  <width>40</width>
                                  <height>20</height>
                                 </size>
                                </property>
                               </spacer>
                              </item>
                              <item row="1" column="5">
                               <widget class="QLabel" name="label_5">
                                <property name="text">
                                 <string>Elapsed:</string>
                                </property>
                               </widget>
                              </item>
                              <item row="1" column="6">
                               <widget class="QLabel" name="plblElapsed">
                                <property name="text">
                                 <string>##:##:##.###</string>
                                </property>
                               </widget>
                              </item>
                              <item row="2" column="0" colspan="7">
                               <widget class="QGroupBox" name="pgrpTrainees">
                                <property name="sizePolicy">
                                 <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                  <horstretch>1</horstretch>
                                  <verstretch>1</verstretch>
                                 </sizepolicy>
                                </property>
                                <property name="title">
                                 <string/>
                                </property>
                                <property name="flat">
                                 <bool>true</bool>
                                </property>
                                <widget class="QWidget" name="verticalLayoutWidget">
                                 <property name="geometry">
                                  <rect>
                                   <x>0</x>
                                   <y>0</y>
                                   <width>600</width>
                                   <height>585</height>
                                  </rect>
                                 </property>
                                 <layout class="QVBoxLayout" name="pvtloTrainees">
                                  <item>
                                   <layout class="QVBoxLayout" name="pvbloT0">
                                    <item>
                                     <layout class="QHBoxLayout" name="phzloT0">
                                      <item>
                                       <widget class="QLabel" name="plblT0">
                                        <property name="enabled">
                                         <bool>true</bool>
                                        </property>
                                        <property name="sizePolicy">
                                         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                          <horstretch>0</horstretch>
                                          <verstretch>0</verstretch>
                                         </sizepolicy>
                                        </property>
                                        <property name="styleSheet">
                                         <string notr="true"/>
                                        </property>
                                        <property name="text">
                                         <string>Trainee:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTN0">
                                        <property name="text">
                                         <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <spacer name="sprT0">
                                        <property name="orientation">
                                         <enum>Qt::Horizontal</enum>
                                        </property>
                                        <property name="sizeHint" stdset="0">
                                         <size>
                                          <width>40</width>
                                          <height>20</height>
                                         </size>
                                        </property>
                                       </spacer>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTBlocks0">
                                        <property name="text">
                                         <string>Blocks:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTB0">
                                        <property name="text">
                                         <string>#######</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTE0">
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="layoutDirection">
                                       <enum>Qt::LeftToRight</enum>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                      </property>
                                      <property name="text">
                                       <string/>
                                      </property>
                                      <property name="textFormat">
                                       <enum>Qt::AutoText</enum>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QProgressBar" name="ppgbT0">
                                      <property name="value">
                                       <number>0</number>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <layout class="QVBoxLayout" name="pvbloT1">
                                    <item>
                                     <layout class="QHBoxLayout" name="phzloT1">
                                      <item>
                                       <widget class="QLabel" name="plblT1">
                                        <property name="enabled">
                                         <bool>true</bool>
                                        </property>
                                        <property name="sizePolicy">
                                         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                          <horstretch>0</horstretch>
                                          <verstretch>0</verstretch>
                                         </sizepolicy>
                                        </property>
                                        <property name="styleSheet">
                                         <string notr="true"/>
                                        </property>
                                        <property name="text">
                                         <string>Trainee:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTN1">
                                        <property name="text">
                                         <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <spacer name="sprT1">
                                        <property name="orientation">
                                         <enum>Qt::Horizontal</enum>
                                        </property>
                                        <property name="sizeHint" stdset="0">
                                         <size>
                                          <width>40</width>
                                          <height>20</height>
                                         </size>
                                        </property>
                                       </spacer>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTBlocks1">
                                        <property name="text">
                                         <string>Blocks:</string>
                                       </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTB1">
                                        <property name="text">
                                         <string>#######</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTE1">
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="layoutDirection">
                                       <enum>Qt::LeftToRight</enum>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                      </property>
                                      <property name="text">
                                       <string/>
                                      </property>
                                      <property name="textFormat">
                                       <enum>Qt::AutoText</enum>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QProgressBar" name="ppgbT1">
                                      <property name="value">
                                       <number>0</number>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                  <layout class="QVBoxLayout" name="pvbloT2">
                                    <item>
                                     <layout class="QHBoxLayout" name="phzloT2">
                                      <item>
                                       <widget class="QLabel" name="plblT2">
                                        <property name="enabled">
                                         <bool>true</bool>
                                        </property>
                                        <property name="sizePolicy">
                                         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                          <horstretch>0</horstretch>
                                          <verstretch>0</verstretch>
                                         </sizepolicy>
                                        </property>
                                        <property name="styleSheet">
                                         <string notr="true"/>
                                        </property>
                                        <property name="text">
                                         <string>Trainee:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTN2">
                                        <property name="text">
                                         <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <spacer name="sprT2">
                                        <property name="orientation">
                                         <enum>Qt::Horizontal</enum>
                                        </property>
                                        <property name="sizeHint" stdset="0">
                                         <size>
                                          <width>40</width>
                                          <height>20</height>
                                         </size>
                                        </property>
                                       </spacer>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTBlocks2">
                                        <property name="text">
                                         <string>Blocks:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTB2">
                                        <property name="text">
                                         <string>#######</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTE2">
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="layoutDirection">
                                       <enum>Qt::LeftToRight</enum>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                      </property>
                                      <property name="text">
                                       <string/>
                                      </property>
                                      <property name="textFormat">
                                       <enum>Qt::AutoText</enum>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QProgressBar" name="ppgbT2">
                                      <property name="value">
                                       <number>0</number>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <layout class="QVBoxLayout" name="pvbloT3">
                                    <item>
                                     <layout class="QHBoxLayout" name="phzloT3">
                                      <item>
                                       <widget class="QLabel" name="plblT3">
                                        <property name="enabled">
                                         <bool>true</bool>
                                        </property>
                                        <property name="sizePolicy">
                                         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                          <horstretch>0</horstretch>
                                          <verstretch>0</verstretch>
                                         </sizepolicy>
                                        </property>
                                        <property name="styleSheet">
                                         <string notr="true"/>
                                        </property>
                                        <property name="text">
                                         <string>Trainee:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTN3">
                                        <property name="text">
                                         <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <spacer name="sprT3">
                                        <property name="orientation">
                                         <enum>Qt::Horizontal</enum>
                                        </property>
                                        <property name="sizeHint" stdset="0">
                                         <size>
                                          <width>40</width>
                                          <height>20</height>
                                         </size>
                                        </property>
                                       </spacer>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTBlocks3">
                                        <property name="text">
                                         <string>Blocks:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTB3">
                                        <property name="text">
                                         <string>#######</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </item>
                                    <item>
                                     <widget class="QProgressBar" name="ppgbT3">
                                      <property name="value">
                                       <number>0</number>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <layout class="QVBoxLayout" name="pvbloT4">
                                    <item>
                                     <layout class="QHBoxLayout" name="phzloT4">
                                      <item>
                                       <widget class="QLabel" name="plblT4">
                                        <property name="enabled">
                                         <bool>true</bool>
                                        </property>
                                        <property name="sizePolicy">
                                         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                          <horstretch>0</horstretch>
                                          <verstretch>0</verstretch>
                                         </sizepolicy>
                                        </property>
                                        <property name="styleSheet">
                                         <string notr="true"/>
                                        </property>
                                        <property name="text">
                                         <string>Trainee:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTN4">
                                        <property name="text">
                                         <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <spacer name="sprT4">
                                        <property name="orientation">
                                         <enum>Qt::Horizontal</enum>
                                        </property>
                                        <property name="sizeHint" stdset="0">
                                         <size>
                                          <width>40</width>
                                          <height>20</height>
                                         </size>
                                        </property>
                                       </spacer>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTBlocks4">
                                        <property name="text">
                                         <string>Blocks:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTB4">
                                        <property name="text">
                                         <string>#######</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTE4">
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="layoutDirection">
                                       <enum>Qt::LeftToRight</enum>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                      </property>
                                      <property name="text">
                                       <string/>
                                      </property>
                                      <property name="textFormat">
                                       <enum>Qt::AutoText</enum>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QProgressBar" name="ppgbT4">
                                      <property name="value">
                                       <number>0</number>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <layout class="QVBoxLayout" name="pvbloT5">
                                    <item>
                                     <layout class="QHBoxLayout" name="phzloT5">
                                      <item>
                                       <widget class="QLabel" name="plblT5">
                                        <property name="enabled">
                                         <bool>true</bool>
                                        </property>
                                       <property name="sizePolicy">
                                         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                          <horstretch>0</horstretch>
                                          <verstretch>0</verstretch>
                                         </sizepolicy>
                                        </property>
                                       <property name="styleSheet">
                                         <string notr="true"/>
                                        </property>
                                        <property name="text">
                                         <string>Trainee:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTN5">
                                        <property name="text">
                                         <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <spacer name="sprT5">
                                        <property name="orientation">
                                         <enum>Qt::Horizontal</enum>
                                        </property>
                                        <property name="sizeHint" stdset="0">
                                         <size>
                                          <width>40</width>
                                          <height>20</height>
                                         </size>
                                        </property>
                                       </spacer>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTBlocks5">
                                        <property name="text">
                                         <string>Blocks:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTB5">
                                        <property name="text">
                                         <string>#######</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTE5">
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="layoutDirection">
                                       <enum>Qt::LeftToRight</enum>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                      </property>
                                      <property name="text">
                                       <string/>
                                      </property>
                                      <property name="textFormat">
                                       <enum>Qt::AutoText</enum>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QProgressBar" name="ppgbT5">
                                      <property name="value">
                                       <number>0</number>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <layout class="QVBoxLayout" name="pvbloT6">
                                    <item>
                                     <layout class="QHBoxLayout" name="phzloT6">
                                      <item>
                                       <widget class="QLabel" name="plblT6">
                                        <property name="enabled">
                                         <bool>true</bool>
                                        </property>
                                        <property name="sizePolicy">
                                         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                          <horstretch>0</horstretch>
                                          <verstretch>0</verstretch>
                                         </sizepolicy>
                                        </property>
                                        <property name="styleSheet">
                                         <string notr="true"/>
                                        </property>
                                        <property name="text">
                                         <string>Trainee:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTN6">
                                        <property name="text">
                                         <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <spacer name="sprT6">
                                        <property name="orientation">
                                         <enum>Qt::Horizontal</enum>
                                        </property>
                                        <property name="sizeHint" stdset="0">
                                         <size>
                                          <width>40</width>
                                          <height>20</height>
                                         </size>
                                        </property>
                                       </spacer>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTBlocks6">
                                        <property name="text">
                                         <string>Blocks:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTB6">
                                        <property name="text">
                                         <string>#######</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTE6">
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="layoutDirection">
                                       <enum>Qt::LeftToRight</enum>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                      </property>
                                      <property name="text">
                                       <string/>
                                      </property>
                                      <property name="textFormat">
                                       <enum>Qt::AutoText</enum>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QProgressBar" name="ppgbT6">
                                      <property name="value">
                                       <number>0</number>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                  <item>
                                   <layout class="QVBoxLayout" name="pvbloT7">
                                    <item>
                                     <layout class="QHBoxLayout" name="phzloT7">
                                      <item>
                                       <widget class="QLabel" name="plblT7">
                                        <property name="enabled">
                                         <bool>true</bool>
                                        </property>
                                        <property name="sizePolicy">
                                         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                         <horstretch>0</horstretch>
                                          <verstretch>0</verstretch>
                                         </sizepolicy>
                                        </property>
                                        <property name="styleSheet">
                                         <string notr="true"/>
                                        </property>
                                        <property name="text">
                                         <string>Trainee:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTN7">
                                        <property name="text">
                                         <string>ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <spacer name="sprT7">
                                        <property name="orientation">
                                         <enum>Qt::Horizontal</enum>
                                        </property>
                                        <property name="sizeHint" stdset="0">
                                         <size>
                                          <width>40</width>
                                          <height>20</height>
                                         </size>
                                        </property>
                                       </spacer>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTBlocks7">
                                        <property name="text">
                                         <string>Blocks:</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QLabel" name="plblTB7">
                                        <property name="text">
                                         <string>#######</string>
                                        </property>
                                        <property name="alignment">
                                         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </item>
                                    <item>
                                     <widget class="QLabel" name="plblTE7">
                                      <property name="sizePolicy">
                                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
                                        <horstretch>0</horstretch>
                                        <verstretch>0</verstretch>
                                       </sizepolicy>
                                      </property>
                                      <property name="layoutDirection">
                                      <enum>Qt::LeftToRight</enum>
                                      </property>
                                      <property name="styleSheet">
                                       <string notr="true">background-color:#ff0000;color:#ffff00;font-weight:bold;</string>
                                      </property>
                                      <property name="text">
                                       <string/>
                                      </property>
                                      <property name="textFormat">
                                       <enum>Qt::AutoText</enum>
                                      </property>
                                      <property name="alignment">
                                       <set>Qt::AlignCenter</set>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QProgressBar" name="ppgbT7">
                                      <property name="value">
                                       <number>0</number>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </item>
                                 </layout>
                                </widget>
                               </widget>
                              </item>
                              <item row="4" column="6">
                               <widget class="QPushButton" name="pbtnAbort">
                                <property name="minimumSize">
                                 <size>
                                  <width>80</width>
                                  <height>24</height>
                                 </size>
                                </property>
                                <property name="text">
                                 <string>&amp;Abort</string>
                                </property>
                               </widget>
                              </item>
                             </layout>
                            </widget>
                          </widget>
                          <resources/>
                          <connections/>
                          </ui>
                          

                          I am trying to locate a widget that is a child of this layout with:

                          QWidget* pobjFound(mpui->pvtloTrainees->findChild<QWidget*>(cstrCtrlKey));
                          

                          Where cstrCtrlKey is a string containing something like ppgbT0, but pobjFound is returned as 0x0 ?

                          J.HilkJ Online
                          J.HilkJ Online
                          J.Hilk
                          Moderators
                          wrote on last edited by
                          #11

                          @SPlatten as stated beforehand

                          Layout cannot be parent of a widget...

                          use <widget class="QWidget" name="verticalLayoutWidget">instead.


                          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                          Q: What's that?
                          A: It's blue light.
                          Q: What does it do?
                          A: It turns blue.

                          SPlattenS 1 Reply Last reply
                          0
                          • J.HilkJ J.Hilk

                            @SPlatten as stated beforehand

                            Layout cannot be parent of a widget...

                            use <widget class="QWidget" name="verticalLayoutWidget">instead.

                            SPlattenS Offline
                            SPlattenS Offline
                            SPlatten
                            wrote on last edited by
                            #12

                            @J-Hilk , thank you, trying that now, why when you dereference the layout does it come up with the findChild suggestion as well as others, it compiles with no errors or warnings?

                            Kind Regards,
                            Sy

                            J.HilkJ 1 Reply Last reply
                            0
                            • SPlattenS SPlatten

                              @J-Hilk , thank you, trying that now, why when you dereference the layout does it come up with the findChild suggestion as well as others, it compiles with no errors or warnings?

                              J.HilkJ Online
                              J.HilkJ Online
                              J.Hilk
                              Moderators
                              wrote on last edited by
                              #13

                              @SPlatten because findChild is a function of QObject

                              However QWidgets based classes requiere a QWidget and not a QObject as a parent. Layouts are no QWidgets


                              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                              Q: What's that?
                              A: It's blue light.
                              Q: What does it do?
                              A: It turns blue.

                              1 Reply Last reply
                              2

                              • Login

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