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
Qt 6.11 is out! See what's new in the release blog

Qmake

Scheduled Pinned Locked Moved Solved Qt for Python
10 Posts 3 Posters 2.5k Views 1 Watching
  • 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 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.

    JonBJ 1 Reply Last reply
    0
    • CristianMaureiraC Offline
      CristianMaureiraC Offline
      CristianMaureira
      wrote on 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

        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.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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
        0
        • JonBJ JonB

          @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 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?

          JonBJ 2 Replies Last reply
          0
          • T Teju

            @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?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #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
            0
            • JonBJ JonB

              @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 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

                @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?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on 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
                0
                • JonBJ JonB

                  @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 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.

                  JonBJ 1 Reply Last reply
                  0
                  • T Teju

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

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on 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
                    0
                    • JonBJ JonB

                      @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 last edited by
                      #10

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

                      1 Reply Last reply
                      0

                      • Login

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