im using QPixmap to load image and set the position.
Image loads in my main window but the position of image is not setting i used setPos
but didn\'t happen anythin
The following concepts must be clear:
QPixmap is not a visual element but a container for the bits that make up the image so they don't have any setPos()
method (recommendation: check the Qt docs).
The visual element that shows the content of the QPixmap in your code is the QLabel so you must set the position to that widget, but in this case the OP is using layouts that aim to manage the geometry (position and size) so you should not use it if you want to set it manually.
def InitWindow(self):
self.setWindowIcon(QtGui.QIcon("icon.png"))
self.setWindowTitle(self.title)
self.setStyleSheet("background-color:#202020")
self.setGeometry(self.left, self.top, self.width, self.height)
labelImage = QLabel(self)
pixmap = QPixmap("mario.png")
pixmap = pixmap.scaled(50, 50, QtCore.Qt.KeepAspectRatio)
labelImage.setPixmap(pixmap)
labelImage.move(100, 100)
self.show()