A
A
Alexman140032018-02-04 11:21:14
Python
Alexman14003, 2018-02-04 11:21:14

How to run a PyQt5 application?

I installed python, PyCharm, PyQt5 (via pip and downloaded pyqt5 gpl), but it gives an error this application failed to start Qt and the Python program stopped working. How to decide?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Rublev, 2018-02-06
@Meller008

Since no one answers, then I will show how it happens for me. I can't help anymore I'm afraid!
I'm not saying what I'm doing right, but it works for me)
I also installed PyQt not through PIP. I am using Qt5.5.1 ( https://sourceforge.net/projects/pyqt/files/PyQt5/...

# main фаил
from PyQt5.QtWidgets import QApplication
import sys, traceback, time
import form.main_window

if __name__ == '__main__':
    app = QApplication(sys.argv)
    main = form.main_window.MainWindow()
    sys.exit(app.exec_())

# Класс MainWindow который запускается в главном файле
from os import getcwd
from PyQt5.QtWidgets import QMainWindow,
from PyQt5.uic import loadUi

class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        loadUi(getcwd() + '/ui/main_window.ui', self)  # Путь к UI файлу сгенерированый QtCreator
        self.show()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question