Search code examples
qtqt5qt-designer

How to hide a widget created by QtDesigner "design" mode programmatically?


I want to know how to create a QLabel in QtCreator Design mode that is hidden by default?
In the properties list in the right hand side panel , there's not any option regarding visibility and also adding label->hide() to setupUi function (after compiling ui file and adding to the project headers) makes no difference.


Solution

  • Designer doesn't expose the visible property. You could hand-edit the UI file, but that will be overwritten next time you edit in Designer. It's best to leave it visible in Designer, and just write a line of code after you call setupUi() to hide the widget you don't want to be initially shown.