Unsolved problem with paths (or QPainter)
-
Oh, yeah!
It works! And I slightly understand what was the trouble.
But it's not easy to realize how .app file may be both executable and also 'directory' for it's data.
Anyway now I can continue my play with images.Many thanks!
-
Hi,
@loa3 said in problem with paths (or QPainter):
.app file may be both executable and also 'directory' for it's data.
They are not both. In fact they are specially treated folders. Look for app bundle in macOS developer documentation.
-
For those who targetting MacOS (IOS ?) only,
it's possible to use the app bundle as a resources container.To copy the contents of a folder in the Resources folder in the app bundle, add the folllowing in the .pro file:
# the img folder is in the project folder (same level as the project file) IMAGES.files = $$files(img/*.jpg) IMAGES.path = contents/resources/img QMAKE_BUNDLE_DATA += IMAGES
Note that the img folder is created automatically if it doesn't exist , cool feature !
I try to do the same things the Qt way with RESOURCES
RESOURCES +=$$files(img/*.jpg)
the folder appears in the left panel hierarchy tree, but it doesn't work because no qrc is created.Any magic command for that ?
-
@SGaist said in problem with paths (or QPainter):
They are not both. In fact they are specially treated folders. Look for app bundle in macOS developer documentation.
I understand. It was like a joke (take into account my poor English).
-
@mpergand said in problem with paths (or QPainter):
For those who targetting MacOS (IOS ?) only,
it's possible to use the app bundle as a resources container.It is very helpful information. I proposed that something like this.
But in fact now my apps should be 'universal'. Since the 'teacher' use Win to check my exercises (as well as Qt with MinGW).
-
@mpergand said in problem with paths (or QPainter):
it doesn't work because no qrc is created.
Again: Qt way to handle it is to create resource file and put the images in the resource file. This way when the bundle is created all the resources are properly put.
Modifying app bundle by putting surplus data in it is not advisable. You might run into the problems later, when signing and verifying deployment bundle.
Besides, there is not need to reinvent the wheel. -
@artwaw said in problem with paths (or QPainter):
Modifying app bundle by putting surplus data in it is not advisable. Y
macx {
QMAKE_INFO_PLIST = Mac/Info.plist
ICON = Mac/AppIcon.icns
}Where do you think these two files go ?
A bundle is a directory with a standardized hierarchical structure that holds executable code and the resources used by that code. The bundle contains resources that may be accessed at runtime, such as images, audio files, user interface files, and property lists.
If you don’t use Xcode to build your software product, use the information below to place your bundled content in the right location.
If you put content in the wrong location, you may encounter hard-to-debug code signing and distribution problems.All that seems obvious, but what's wrong with Qt Apps ?
If there are issues, it is a Qt problem, not mine. -
@mpergand There is nothing wrong with Qt Apps.
My point is that there no need to fiddle with resources (and rare case when you need to adjust info.plist) since Qt offers you ready solutions to handle it.@mpergand said in problem with paths (or QPainter):
If there are issues, it is a Qt problem, not mine.
O'rly
-
Where do you think these two files go ?
the info.plist actually not in your app bundle, at least not the one you mark in that way. the app bundle contains the binary version of it, not the human readable one
I try to do the same things the Qt way with RESOURCES
RESOURCES +=$$files(img/*.jpg)
the folder appears in the left panel hierarchy tree, but it doesn't work because no qrc is created.right click on your project -> add new -> Files and Classes - Qt -> Qt Resource File
than right click on the resource file -> add existing file/directory
-
@J-Hilk said in problem with paths (or QPainter):
the app bundle contains the binary version of it, not the human readable one
If I look at Preview app, info.plist is a text file, but not writable.
Maybe a extra process is needed to serialize the bundle ?right click on your project -> add new -> Files and Classes - Qt -> Qt Resource File
than right click on the resource file -> add existing file/directory
Yes I know, I was asking for an automatic process with a qmake command.