how to display widget in mainwindow in pyqt5 code example
Example: pyqt add widget to window
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, \
QPushButton, QVBoxLayout
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
layout = QVBoxLayout()
btn = QPushButton("Click")
layout.addWidget(btn)
w = QWidget()
w.setLayout(layout)
self.setCentralWidget(w)
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
sys.exit(app.exec_())