Solved QIODevice cannot open .ui file from resources.
-
@zspinelli
So that's the explanation for the error! That's all I was saying. -
@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. -
@zspinelli
I assume your form resource is not at:/_qtresources/ui/NewDocumentForm.ui
. -
@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. -
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.
-
@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. -
@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?
-
If the one you have supports Python code generation, then use it.
-
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".
-
@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.