Opening the same QtGui on a different windows system results in different displaying of the label size or frame size that makes thing ugly .I have compiled my pyqt4
application with cx_freeze
to .exe file and when I open my application in another machine some labels have smaller size and some part of the text in label can not be seen .why this happen and how can I fix this ? sorry for my bad English.

- 1,148
- 2
- 15
- 27
2 Answers
Qt uses the native windows system widget styling info to render it's GUI. This makes the GUI look more like a proper native application. If you are using fixed widget positioning to lay out your GUI, such as you generally get with QtDesigner, this can cause problems because the widget sizes may vary on target platforms.
An alternative is to use the layout controls such as QHBoxLayout, QVBoxLayout, etc which resize the layout to accomodate the size of the widgets. Another way is to override the native theme with a specific theme so your app looks the same regardless of the platform.

- 5,941
- 5
- 26
- 32
Label font and size depends on the setting of specific machine where you run the app. Also it depends on the platform of the machine. You may try to fix the font setting of your application to some specific setup by setFont method (see example below) but be aware that this will ignore the local user preferences (which may include increased font size for better visibility) and it may lead your app to even worse look if requested font doesn't exist at your target computer.
class MainForm(QtGui.QMainWindow):
def __init__(self):
super().__init__()
self.setFont(QtGui.QFont("Calibri", 10))
Update: Sorry, misundestood your initial question. The label width can be fixed in specific limits by calling setMinimumWidth and setMaximumWidth with the needed width provided. So in your case I would set the minimum width to fully show the label text all the time.
class MainForm(QtGui.QMainWindow):
def __init__(self):
super().__init__()
self.label = QtGui.QLabel("Test")
self.label.setMinimumWidth(100)

- 21
- 2
-
tnx for your answer .but I'm talking about label size not the text in label. – alizx Nov 22 '13 at 21:02