Ui, finding control by using literal string
-
wrote on 22 Oct 2021, 09:21 last edited by
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.
-
@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>&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 ?
@SPlatten as stated beforehand
Layout cannot be parent of a widget...
use
<widget class="QWidget" name="verticalLayoutWidget">
instead. -
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.
@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 -
@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 -
@jsulm , I want to address by objectName, so for example, something like:
QProgressBar* pBar(ui->find("name")); pBar->setValue(123);
@SPlatten Isn't https://doc.qt.io/qt-5/qobject.html#findChildren what you need?
-
@SPlatten Isn't https://doc.qt.io/qt-5/qobject.html#findChildren what you need?
-
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
-
@SPlatten You pass the pointer to the parent widget which contains the widgets you want to search...
-
@SPlatten You pass the pointer to the parent widget which contains the widgets you want to search...
-
@SPlatten Layout cannot be parent of a widget...
Simply use the widget containing this layout and the child widgets... -
@SPlatten Layout cannot be parent of a widget...
Simply use the widget containing this layout and the child widgets...wrote on 22 Oct 2021, 11:41 last edited by@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>&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 ?
-
@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>&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 ?
@SPlatten as stated beforehand
Layout cannot be parent of a widget...
use
<widget class="QWidget" name="verticalLayoutWidget">
instead. -
@SPlatten as stated beforehand
Layout cannot be parent of a widget...
use
<widget class="QWidget" name="verticalLayoutWidget">
instead.wrote on 22 Oct 2021, 11:51 last edited by@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-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?
@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
1/13