When I run the following code, the label
widget (?) shows even though it hasn't been added to any layout.
The textbook I'm following also implies I shouldn't be seeing it (until I add it to a layout), but it's appearing anyway. I was expecting to see an empty window. Any thoughts?
import sys
from PyQt5 import QtWidgets as qtw
from PyQt5 import QtGui as qtg
from PyQt5 import QtCore as qtc
class MainWindow(qtw.QWidget):
def __init__(self):
"""MainWindow constructor"""
super().__init__(windowTitle='Hello world')
# QWidget
subwidget = qtw.QWidget(self, toolTip='This is my widget')
subwidget.setToolTip('This is YOUR widget')
print(subwidget.toolTip())
# QLabel
label = qtw.QLabel('<b>Hello Widgets!</b>', self, margin=10)
self.show()
if __name__ == '__main__':
app = qtw.QApplication(sys.argv)
mw = MainWindow()
sys.exit(app.exec())