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



  • A project I worked on back in 2016 is throwing lots of someWidget is not a member of UI:someForm errors. 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&amp;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 btnSaveCurrent and cmbMethod are declared in the UI file. But if I put the cursor at the end of widget. and hit Ctrl-Space, we can see that btnSaveCurrent is actually visible in the consuming class, while cmbMethod is not.

    alt text

    alt text

    I tried dropping a brand new comboBox onto 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 QComboBox was 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?


  • Qt Champions 2019

    Is widget the member which contains the ui elements ? If so you should delete the generated ui_FOO.h file so it's recreated.



  • @Christian-Ehrlicher
    A rebuild did the trick.


Log in to reply