Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Some of widget members visible in the comsuming class, while others are not
In Fo last edited by In Fo
A project I worked on back in 2016 is throwing lots of
someWidget is not a member of UI:someFormerrors. Back then this was a working project, which compiled and ran without any errors. It was committed to source control, deployed to production, and never touched since. Today I am downloading a fresh copy of Qt 5.5.1 and trying to build it to work on a change, but errors like the above are raining on me like cats and dogs.
Here is an example of the UI code:
<widget class="QPushButton" name="btnSaveCurrent"> <property name="geometry"> <rect> <x>1030</x> <y>350</y> <width>75</width> <height>25</height> </rect> </property> <property name="text"> <string>Sa&ve</string> </property> </widget> <widget class="QComboBox" name="cmbMethod"> <property name="geometry"> <rect> <x>1160</x> <y>210</y> <width>131</width> <height>22</height> </rect> </property> </widget>
This is one example of how the class uses the UI widgets:
widget.cmbMethod->addItem(tr("Single-threaded"), QVariant(Methods::Single)); widget.cmbMethod->addItem(tr("Parallel"), QVariant(Methods::Parallel));
So we can see that
cmbMethodare declared in the UI file. But if I put the cursor at the end of
widget.and hit Ctrl-Space, we can see that
btnSaveCurrentis actually visible in the consuming class, while
I tried dropping a brand new
comboBoxonto the form, but it was not visible in the code completion drop down either. After two years of not touching Qt my Qt-fu is rusty, so the first thing I checked was that
QComboBoxwas not deprecated, and it apparently was not. Does anyone have a clue why only a portion of the UI would be visible to a consuming class?
Is widget the member which contains the ui elements ? If so you should delete the generated ui_FOO.h file so it's recreated.
In Fo last edited by
A rebuild did the trick.