Grismar
Grismar

Reputation: 31354

Integrate Qt Designer and PyCharm

There are plenty of minor challenges getting PyQt5 and Qt Designer to play nice with PyCharm, but after getting all the small steps in place, I cannot help but wonder if I missed the obvious.

What is the most straightforward way to integrate PyCharm and Qt Designer?

What I did so far:

Answers I'm looking for:

Upvotes: 16

Views: 41617

Answers (3)

Hammad Farooq
Hammad Farooq

Reputation: 11

If you're unable to find the designer.exe file, you can locate it here:

C:\Users\<user>\PycharmProjects\<project>\.venv\Lib\site-packages\qt5_applications\Qt\bin\designer.exe

This path is valid for setups using Python 3.9 with a virtual environment in PyCharm. Replace with your Windows username and with your project's name.

I wanted to add this as a comment to Joker's answer, but since commenting requires 50 reputation, I'm posting it as an answer instead.

Upvotes: 1

Joker
Joker

Reputation: 755

Step by Step instruction on Integrating QT Designer in Pycharm :

  1. Python 3.7 = C:\Users\x\PycharmProjects\Hello\venv\Scripts\python.exe

  2. Pip install following:

    • PyQt5
    • PyQt5-tools
  3. Location of QT designer executable, which is located in - C:\Users\x\PycharmProjects\Hello\venv\Scripts\designer.exe

  4. For QT Designer: File -> Settings -> Tools -> External Tools -> create (+)

    • Name: QTdesigner
    • Program: C:\Users\x\PycharmProjects\Hello\venv\Scripts\designer.exe
    • Arguments: NONE
    • Working directory: $ProjectFileDir$

    OK

  5. For converting UI file to Py file Pyuic: File -> Settings -> Tools -> External Tools -> create (+)

    • Name : PyUIC
    • Program : C:\Users\x\PycharmProjects\Hello\venv\Scripts\pyuic5.exe
    • Arguments: -x $FileName$ -o $FileNameWithoutExtension$.py
    • Working directory: $ProjectFileDir$

    OK

  6. Click Tools -> External Tools -> QTdesigner Design your UI and save it as X.ui

  7. You will have X.ui located in the Project file, a. Right click on X.ui b. External Tools -> PyUIC c. Success

  8. You will be able to see X.py file in the projects folder

  9. Run X.py

  10. You should be able to see your GUI application.

Upvotes: 19

Ian St.John
Ian St.John

Reputation: 311

If you are just looking to open the .ui files in QT Designer, there is a simpler solution.

Go to Settings|File Types and click on "Files Opened in Associated Applications", the go to the Registered Patterns field and add *.ui as a pattern. It will complain that *.ui is already registered to QT Designer. Click OK to reassign the wildcard. Now, when you doubleclick on the .ui file in PyCharm it will open with the associated editor in Windows (which should be Designer).

If PyCharm has already associated the .ui extension with some file type, you can easily override that by selecting the file in the Project browser and selecting File|Associate with File Type... from the menu. Select Open matching files in associated application to have PyCharm open whatever application has been associated with the file type in Windows.

Upvotes: 8

Related Questions