Apr-07-2017, 08:43 PM
I need to be able to dynamically add an object like a label to my window. How do I do that? Here is the code that I have.
class Main(QtGui.QMainWindow, stuff): def __init__(self): QtGui.QMainWindow.__init__(self) self.resize(600, 500) self.setup() def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_A: self.addblock() def addblock(self): self.newblock = QtGui.QLabel(self.frame) self.newblock.setGeometry(QtCore.QRect(10, 10, 40, 40)) self.newblock.setPixmap(self.blockimg)#I use the label to display an image.The problem is when I push the A key I know that the new label is being created but it will not show on the window. How do I get the label to show on the window?