PDA

View Full Version : Qt Creator: Can't find resources from my second form



mikag
19th July 2015, 22:09
I've just started out trying to create a UI from scratch in Qt Creator. Eventually I'm trying to migrate the UI of a legacy app to Qt.
The plan is to create as much of the UI in .ui files as possible to ensure it's visible in the Qt Linguist. If only linguist could use the same ui rendering engine as Designer/Creator, but that's a separate issue.

I've run into what must be a real noob problem. I've created a mainwindow form and a qrc resource file with all our existing images. And all image resources are available when working with the mainwindow form in the Creator Design mode.
Then I added a new widget based form but in Design mode absolutely no resources are available. I did see a note in a forum post that it's possible to have different resource files for each form in a project. But my situation is that I need to have access to the same resource file with images from all forms in my project.

How and where can I connect my existing resource file to the new widget based form?

This was really trivial when working in Designer but here in Creator I just don't understand how to do it. I've been looking everywhere but I must be missing something really obvious here.

Thanks for helping!

anda_skoa
20th July 2015, 07:48
I am not sure I understand, but if stand-alone Designer works better than the integrated one, can't you just use the stand-alone variant?

Cheers,
_

mikag
20th July 2015, 09:02
Well I've previously done a few ui designs in Designer. But now I'm testing working with Creator trying out it's code generation and refactoring support to see if it will save any time for me when porting the legacy apps UI.

The issue I have is rather trivial (I hope).

I have one project with two forms (+ wrapper classes) and one qrc resourse file containing 100+ images.

When using the designer GUI to add an action in Design mode to the mainwindow form I can select an image from the resources. But when adding an action in Design mode to the second widget based form I can't select any images as there's no resource file associated with this form. And the dialog shown shows no resources and no option to specify a resource file.

So the question is: Where is the option to specify the resource file(s) to use for a form?

anda_skoa
20th July 2015, 10:27
Ok, I tried this:

- created a new Qt widgets project
- copied an icon to an image sub folder
- added a Qt resource and added the icon to it
- added a menu to the mainwindow form's menu bar
- added an entry to that menu

at this point I could chose the icon from the resource as the icon of the action that was generated.

- added a dialog form class
- added a button onto it

at this point I could not yet select the icon from the resource

- built the application

now I could also set the ucon on the dialog's button.

Cheers,
_

mikag
20th July 2015, 14:42
So right you are. Once I build and run the project I can access the resources from the new form.
Never tried that, thanks for helping out!