In UI frameworks the widgets draw themselves using resources that are cached or preloaded by the system. Logical objects should not have ownership over shared data. It's bad design in anything that's non-trivial.
In Qt, images are loaded as soon as a QPixmap object is instantiated, causing a lag like the one in my game when lots of large images are being loaded. But anyway, I agree, the widgets shouldn't own the resources. I do have an asset loader already and I can move the image loading into it, and also add caching.
Then you can implement your resource manager as a cache and map resources by URI or something. It really sounds like you're making this more complicated than it needs to be. What kind of GUI needs so many distinct resources that you're afraid to pre-load all of them?
I'm not afraid to preload them all, I think that's going to be necessary. It's only going to be 100-200 MB, so that should be fine even on ancient systems. The OS will page unused resources out anyway. I was thinking that it may be better to have a loading screen for each scene, but I suppose that's not really necessary at this scale.
My problem is that I can't figure out how to preload everything, I never had to think about this before working with less/smaller images. Only the widgets know which images they need, so I see only two options:
1. Instantiate all widgets upfront - they'll load their resources
2. Figure out which images to load without consulting the widgets
Your suggestion sounds like option 2, and it does indeed seem better. Now I'm wondering how to implement that, seeing three options:
2a. Have a mapping between image IDs and image paths - use the image IDs in widgets, preload all the images from the mapping file on startup
2b. Have a file that lists all the resources that should be preloaded
2c. Just load all image files in the directory
2a Seems tedious - I'll have to add every single image file I use there. 2b is similarly tedious and on top of that error prone - it's easy to forget. 2c involves no manual effort, but I have to make assumptions about what to load (e.g. every file name ending with .png) and it may load too much if there are unused resources.
How is that commonly being solved? Considering that many games have loading screens per scene or level, how do they figure out which resources are required upfront?