A layout can not be hidden since they are not widgets and does not have a setVisible() function.
You have to create a widget that you can hide, that contains the layout and the other widgets that should be hidden, then you hide the widget instead of the layout.
QWidget* myWidget = new QWidget();
QHBoxLayout * layout = new QHBoxLayout(myWidget);
layout->addWidget(new QLabel("Label"));
myWidget->setVisible(false);