Python PyQt Qlabel Resize

Tyrell picture Tyrell · Dec 23, 2016 · Viewed 19k times · Source

I'm having trouble here trying to set my Qlabel size to be bigger. Here is my code. I'm not sure what to do. I have tried lots...

def __init__(self, parent=None):
    super(UICreator, self).__init__(parent)
    self.Creator = QPushButton("YouTube", self)
    self.Creator.resize(100, 40)
    self.Creator.move(25, 50)
    self.CreatorB2 = QPushButton("Twitter", self)
    self.CreatorB2.resize(100, 40)
    self.CreatorB2.move(275, 50)
    self.CreatorL = QLabel("Created By:", self)
    self.CreatorL.resize(100, 100)
    self.CreatorL.move(20, 300)

Answer

Inconnu picture Inconnu · Dec 23, 2016

If you're using PyQt4 then make sure you imported:

from PyQt4 import QtCore

then add this line to set size of the label:

self.CreatorL = QLabel("Created By:", self)
self.CreatorL.setGeometry(QtCore.QRect(70, 80, 100, 100)) #(x, y, width, height)