Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking a qtDesigner .ui file to python/pyqt?

So if I go into QtDesigner and build a UI, it'll be saved as a .ui file. How can I make this as a python file or use this in python?

like image 412
Chris Avatar asked Mar 08 '10 01:03

Chris


People also ask

How do I import qt5 in Python?

Enter the mainloop of application by app.Import QtCore, QtGui and QtWidgets modules from PyQt5 package. Create an application object of QApplication class. Add a QLabel object and set the caption of label as "hello world". Define the size and position of window by setGeometry() method.


1 Answers

Another way to use .ui in your code is:

from PyQt4 import QtCore, QtGui, uic class MyWidget(QtGui.QWidget)     ...     #somewhere in constructor:     uic.loadUi('MyWidget.ui', self) 

both approaches are good. Do not forget, that if you use Qt resource files (extremely useful) for icons and so on, you must compile it too:

pyrcc4.exe -o ui/images_rc.py ui/images/images.qrc 

Note, when uic compiles interface, it adds 'import images_rc' at the end of .py file, so you must compile resources into the file with this name, or rename it in generated code.

like image 198
Maxim Popravko Avatar answered Sep 24 '22 04:09

Maxim Popravko