Answer the question
In order to leave comments, you need to log in
How to make QMainWindow close by button on QDockWidget?
Good day. It is necessary to add the closing of the main window by the QPushButton button. I can't find any information on how to do this. Here is part of my code
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.browser = QWebEngineView()
self.browser.setUrl(QUrl("http://yandex.ru"))
self.browser.urlChanged.connect(self.update_urlbar)
self.browser.loadFinished.connect(self.update_title)
self.setCentralWidget(self.browser)
self.status = QStatusBar()
self.setStatusBar(self.status)
## QDockWidget ##
self.docked = QDockWidget("Виджет", self)
self.addDockWidget(Qt.LeftDockWidgetArea, self.docked)
self.dockedWidget = QWidget(self)
self.docked.setWidget(self.dockedWidget)
self.dockedWidget.setLayout(QVBoxLayout())
self.dockedWidget.layout().addWidget(QPushButton('Завершить работу'))
Answer the question
In order to leave comments, you need to log in
self.closeBtn = QPushButton(self.tr('Close'))
self.closeBtn.clicked.connect(self.close)
self.dockedWidget.layout().addWidget(self.closeBtn)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question