Embed Widgets Into Qwindow
Basically I want to create a window using QtGui.QWindow() instead of QtWidgets.QMainWindow(). I want to do this because I want to have access to QWindow functions such as: startSy
Solution 1:
So that there is an XY problem since the objective is to modify properties of the QWindow associated with the QWidget but instead it asks how to embed a QWidget into a QWindow.
QWidget creates a QWindow after using the show() method and it can be accessed using the windowHandle() method.
import sys
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtWidgets import QApplication, QMainWindow
defmain():
app = QApplication(sys.argv)
mainwindow = QMainWindow()
mainwindow.show()
window = mainwindow.windowHandle()
window.setTitle("Foo")
defstart_resize():
window.startSystemResize(Qt.TopEdge)
defstart_move():
window.startSystemMove()
defmaximized():
window.setWindowStates(Qt.WindowMaximized)
QTimer.singleShot(5 * 1000, start_resize)
QTimer.singleShot(10 * 1000, start_move)
QTimer.singleShot(15 * 1000, maximized)
sys.exit(app.exec())
if __name__ == "__main__":
main()
Note: Some methods of the QWidget are a wrapper of the QWindow methods such as setWindowTitle() or setWindowState().
Post a Comment for "Embed Widgets Into Qwindow"