I have a simple example to hide/show button and in show mode, everything works as expected. Ok
In hide mode, I excepted that the "Toggle" button only to be displayed [ok], but the size of the "Toggle" button is wider that the original one. I excepted also, that the main windows is being resized as well.

class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.centralWidget = QWidget()
self.setCentralWidget(self.centralWidget)
self.layout = QHBoxLayout(self.centralWidget)
self.button1 = QPushButton("Hide-1") # Button-1
self.layout.addWidget(self.button1)
self.button2 = QPushButton("Hide-2") # Button-2
self.layout.addWidget(self.button2)
self.button3 = QPushButton("Toggle") # Button-
self.button3.clicked.connect(self.hide_unhide)
self.layout.addWidget(self.button3)
def hide_unhide(self):
if self.button1.isVisible():
self.button1.hide()
self.button2.hide()
else:
self.button1.show()
self.button2.show()
self.adjustSize() # This doesn't work
self.centralWidget.adjustSize() # This doesn't work
app= QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()