Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Qmake
QtWS25 Last Chance

Qmake

Scheduled Pinned Locked Moved Solved Qt for Python
10 Posts 3 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Teju
    wrote on 10 Dec 2021, 06:37 last edited by
    #1

    I have created UI using Qtdesigner. I have added my .ui file in python file. But I am not able to see Icons I have set to the TreeWidget I have used. When I searched I understood I need Qmake for that. But I don't know where do I find QMake. Do I have to install it? Or will it come along with pyqt5. Please help me with it.

    J 1 Reply Last reply 10 Dec 2021, 10:35
    0
    • C Offline
      C Offline
      CristianMaureira
      wrote on 10 Dec 2021, 10:32 last edited by
      #2

      Hey there,
      if you have an .ui file, then you need to generate the a python file equivalent, to later load it from your code, like described here https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#option-a-generating-a-python-class

      PySide, and also PyQt, include the tools to work on ui file, called pyside6-uic and pyqt5-uic respectively, that should be enough to get your application going, but I do encourage you to read the previous tutorial to understand the process.

      1 Reply Last reply
      2
      • T Teju
        10 Dec 2021, 06:37

        I have created UI using Qtdesigner. I have added my .ui file in python file. But I am not able to see Icons I have set to the TreeWidget I have used. When I searched I understood I need Qmake for that. But I don't know where do I find QMake. Do I have to install it? Or will it come along with pyqt5. Please help me with it.

        J Online
        J Online
        JonB
        wrote on 10 Dec 2021, 10:35 last edited by
        #3

        @Teju said in Qmake:

        But I am not able to see Icons I have set to the TreeWidget I have used.

        What exactly do you mean by this? @CristianMaureira's suggestion of generating Python classes from .ui files at development time may certianly be a good idea, but I don't know how it relates to whatever problem you are having.

        T 1 Reply Last reply 10 Dec 2021, 14:18
        0
        • J JonB
          10 Dec 2021, 10:35

          @Teju said in Qmake:

          But I am not able to see Icons I have set to the TreeWidget I have used.

          What exactly do you mean by this? @CristianMaureira's suggestion of generating Python classes from .ui files at development time may certianly be a good idea, but I don't know how it relates to whatever problem you are having.

          T Offline
          T Offline
          Teju
          wrote on 10 Dec 2021, 14:18 last edited by
          #4

          @JonB I have set Folder Icon to entire TreeWidget in Qtdesigner adding resource file. When I preview the window it shows exactly how I designed with icons. But when I link the file to my .py file (by using loadUi(.ui) ) everything and after running the entire program I am not able to see the icons I have added to TreeWidget.
          So is it issue of .qrc files? Or .ui file?

          J 2 Replies Last reply 10 Dec 2021, 16:32
          0
          • T Teju
            10 Dec 2021, 14:18

            @JonB I have set Folder Icon to entire TreeWidget in Qtdesigner adding resource file. When I preview the window it shows exactly how I designed with icons. But when I link the file to my .py file (by using loadUi(.ui) ) everything and after running the entire program I am not able to see the icons I have added to TreeWidget.
            So is it issue of .qrc files? Or .ui file?

            J Online
            J Online
            JonB
            wrote on 10 Dec 2021, 16:32 last edited by JonB 12 Oct 2021, 16:34
            #5

            @Teju
            I understand now. With a C++ Qt program, resources get compiled into the final excutable. But obviously with Python there is no such thing. I don't know how resources are accessed from a Python Qt program. You are using PyQt5, you say, so did you Google for, say, pyqt5 access qt resource, or similar? Does, say, https://www.pythonguis.com/tutorials/qresource-system/ help? I think they are saying you would execute pyrcc5 resources.qrc -o resources.py?

            Another alternative to consider, especially if you do not have many resources in your app: why bother with resources and this step at all? You could just access the icon in an external file you supply with your Python file(s).

            T 1 Reply Last reply 11 Dec 2021, 12:16
            0
            • J JonB
              10 Dec 2021, 16:32

              @Teju
              I understand now. With a C++ Qt program, resources get compiled into the final excutable. But obviously with Python there is no such thing. I don't know how resources are accessed from a Python Qt program. You are using PyQt5, you say, so did you Google for, say, pyqt5 access qt resource, or similar? Does, say, https://www.pythonguis.com/tutorials/qresource-system/ help? I think they are saying you would execute pyrcc5 resources.qrc -o resources.py?

              Another alternative to consider, especially if you do not have many resources in your app: why bother with resources and this step at all? You could just access the icon in an external file you supply with your Python file(s).

              T Offline
              T Offline
              Teju
              wrote on 11 Dec 2021, 12:16 last edited by
              #6

              @JonB Another alternative to consider, especially if you do not have many resources in your app: why bother with resources and this step at all? You could just access the icon in an external file you supply with your Python file(s).

              Sorry I did not get what you mean? Like how do I access the icon externally ? Could you please elaborate?

              1 Reply Last reply
              0
              • T Teju
                10 Dec 2021, 14:18

                @JonB I have set Folder Icon to entire TreeWidget in Qtdesigner adding resource file. When I preview the window it shows exactly how I designed with icons. But when I link the file to my .py file (by using loadUi(.ui) ) everything and after running the entire program I am not able to see the icons I have added to TreeWidget.
                So is it issue of .qrc files? Or .ui file?

                J Online
                J Online
                JonB
                wrote on 11 Dec 2021, 12:19 last edited by
                #7

                @Teju said in Qmake:

                I have set Folder Icon to entire TreeWidget in Qtdesigner adding resource file.

                Where you set the icon from a resource file, you had the choice of just selecting an external file on disk instead?

                T 1 Reply Last reply 11 Dec 2021, 12:54
                0
                • J JonB
                  11 Dec 2021, 12:19

                  @Teju said in Qmake:

                  I have set Folder Icon to entire TreeWidget in Qtdesigner adding resource file.

                  Where you set the icon from a resource file, you had the choice of just selecting an external file on disk instead?

                  T Offline
                  T Offline
                  Teju
                  wrote on 11 Dec 2021, 12:54 last edited by
                  #8

                  @JonB yeah. I have tried using that one but when I run the program it doesn't show any icon at all.

                  J 1 Reply Last reply 11 Dec 2021, 13:04
                  0
                  • T Teju
                    11 Dec 2021, 12:54

                    @JonB yeah. I have tried using that one but when I run the program it doesn't show any icon at all.

                    J Online
                    J Online
                    JonB
                    wrote on 11 Dec 2021, 13:04 last edited by
                    #9

                    @Teju
                    It should do, and you should find out why it does not. The usual issue is because it (Qt Designer) puts in a relative path, and at run time that depends on what the current working directory is, which varies depending on how you run your program (and i don't know how you do that). You could ensure you set your working directory to whatever is necessary at the start of your Python script.

                    T 1 Reply Last reply 11 Dec 2021, 14:56
                    0
                    • J JonB
                      11 Dec 2021, 13:04

                      @Teju
                      It should do, and you should find out why it does not. The usual issue is because it (Qt Designer) puts in a relative path, and at run time that depends on what the current working directory is, which varies depending on how you run your program (and i don't know how you do that). You could ensure you set your working directory to whatever is necessary at the start of your Python script.

                      T Offline
                      T Offline
                      Teju
                      wrote on 11 Dec 2021, 14:56 last edited by
                      #10

                      @JonB yes thank you so much it works fine now.

                      1 Reply Last reply
                      0

                      1/10

                      10 Dec 2021, 06:37

                      • Login

                      • Login or register to search.
                      1 out of 10
                      • First post
                        1/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved