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. QIODevice cannot open .ui file from resources.

QIODevice cannot open .ui file from resources.

Scheduled Pinned Locked Moved Solved Qt for Python
13 Posts 3 Posters 3.0k 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.
  • Z zspinelli

    @JonB
    The errorString gives me "No such file or directory"

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #4

    @zspinelli
    So that's the explanation for the error! That's all I was saying.

    Z 1 Reply Last reply
    0
    • JonBJ JonB

      @zspinelli
      So that's the explanation for the error! That's all I was saying.

      Z Offline
      Z Offline
      zspinelli
      wrote on last edited by
      #5

      @JonB
      I just found something now for a tool called rcc. Is that absolutely always neccessary to use qrc stuff?
      If so, I think this might be the problem.

      JonBJ SGaistS 2 Replies Last reply
      0
      • Z zspinelli

        @JonB
        I just found something now for a tool called rcc. Is that absolutely always neccessary to use qrc stuff?
        If so, I think this might be the problem.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #6

        @zspinelli
        I assume your form resource is not at :/_qtresources/ui/NewDocumentForm.ui.

        Z 1 Reply Last reply
        0
        • JonBJ JonB

          @zspinelli
          I assume your form resource is not at :/_qtresources/ui/NewDocumentForm.ui.

          Z Offline
          Z Offline
          zspinelli
          wrote on last edited by
          #7

          @JonB
          That's the exact path to it from the top of the source directory in the file system.
          That's the path resources gave it when I added the form to the project.
          I don't know where it would be if it's not there.

          JonBJ 1 Reply Last reply
          0
          • Z zspinelli

            @JonB
            I just found something now for a tool called rcc. Is that absolutely always neccessary to use qrc stuff?
            If so, I think this might be the problem.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #8

            Hi,

            @zspinelli said in QIODevice cannot open .ui file from resources.:

            @JonB
            I just found something now for a tool called rcc. Is that absolutely always neccessary to use qrc stuff?
            If so, I think this might be the problem.

            Yes that is mandatory. Resources must be first created like in C++. See here.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            Z 1 Reply Last reply
            1
            • Z zspinelli

              @JonB
              That's the exact path to it from the top of the source directory in the file system.
              That's the path resources gave it when I added the form to the project.
              I don't know where it would be if it's not there.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #9

              @zspinelli said in QIODevice cannot open .ui file from resources.:

              That's the exact path to it from the top of the source directory in the file system.

              That's not what you want at runtime. The :/... file path syntax is treated by Qt as referring to a resource compiled into your executable, not a real, external file. Follow @SGaist's link to achieve that.

              Z 1 Reply Last reply
              1
              • SGaistS SGaist

                Hi,

                @zspinelli said in QIODevice cannot open .ui file from resources.:

                @JonB
                I just found something now for a tool called rcc. Is that absolutely always neccessary to use qrc stuff?
                If so, I think this might be the problem.

                Yes that is mandatory. Resources must be first created like in C++. See here.

                Z Offline
                Z Offline
                zspinelli
                wrote on last edited by
                #10

                @SGaist
                The link you posted shows an example using a tool called "pyside6-rcc".
                If that's supposed to be installed with PySide6 then for some reason I don't have it. I found this page https://stackoverflow.com/questions/22479581/cannot-use-pyside-rcc-to-compile-qrc-file mentioning some locations where it might be but it isn't present in any of them.

                However I found another page: https://doc.qt.io/qtforpython/overviews/resources.html showing the use of the regular "rcc" which I do have as part of the Qt installation. Before I try the example shown there, should I know if one is one tool is more preferable than the other?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  If the one you have supports Python code generation, then use it.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    zspinelli
                    wrote on last edited by
                    #12

                    I found pyside6-rcc. I'm going to note for posterity that it was found under C:\Users\<username>\AppData\Roaming\Python\Python39\Scripts

                    I ran it, got the py output as per the demonstration, and imported it. The errorString for the QFile is now "Unknown error".

                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @zspinelli said in QIODevice cannot open .ui file from resources.:

                      That's the exact path to it from the top of the source directory in the file system.

                      That's not what you want at runtime. The :/... file path syntax is treated by Qt as referring to a resource compiled into your executable, not a real, external file. Follow @SGaist's link to achieve that.

                      Z Offline
                      Z Offline
                      zspinelli
                      wrote on last edited by
                      #13

                      @JonB @SGaist
                      After lot of internet searching and fistfighting the code, I got my project back on track and got some other stuff fixed as well.
                      I had pyside6 module installed wrong and was using the wrong approach for integrating the UI form.
                      @SGaist Your recommendation for pyside6-rss led me to pyside6-uic, which was what I really needed.

                      I'm thankful to you both for tolerating and assisting me.

                      1 Reply Last reply
                      2

                      • Login

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