-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iconfont does not work as expected. #48
Comments
URLs pointing to classpath resources start with "file:///:classpath:/". |
Ok, I've followed your instructions on the knee and it's already working as expected. It's strange that some other resources, such as images that only write classpath:... are also ok. With this issue resolved. code:
and in the main form windows
to play, but there is no sound. What is the situation? |
It depends if the property is of type file or url. Classpath resources are internally managed by file engine. Thus, specifying a file (i.e. |
Concerning MediaPlayer: |
There is no error message. Might be an IDEA problem. I don't know how to configure the output information. Like QtCreator, if a header file is missing, it will print on the console when compiling or running. IDEA doesn't seem to be able to do it, can you do it with the Eclipse you used before? If you can, please tell me how to configure it.
|
How do you load QML? With |
public class Application
} It is written as in Qt. |
Are there warnings?
...to be put before |
I can confirm that I am able to hear music from a local file path but not from a classpath. |
I suggest to use metaplayer's setSourceDevice method with QFile as device pointing to classpath resource. |
Here is a solution: for(QObject root : engine.rootObjects()) {
QMediaPlayer player = root.findChild(QMediaPlayer.class, "", Qt.FindChildOption.FindChildrenRecursively);
assert player!=null;
QFile file = new QFile("classpath:/<path_to>.mp3");
file.open(QIODevice.OpenModeFlag.ReadOnly);
player.setSourceDevice(file);
break;
} |
Ok, so far I can say, that |
I was able to solve this issue. engine.load(new QUrl("qrc:qml/main.qml")); Also in QML: MediaPlayer {
source: "qrc:/assets/sound/app.mp3"
} The keyword QIcon icon = new QIcon(":/path/to/icons/icon.png"); |
OK, that's really good news. It's perfect to be able to solve this problem. The qrc keyword appears in your sample code, is he a wrapper for the classpth keyword? |
No, that's Qt specific. If you write C++ code with Qt you can address resources embedded in your binary with a filepath ":/path" (see https://doc.qt.io/qt-6/resources.html). //C++ example:
QFileInfo info(":resource/content.data");
QIcon icon(":images/icon.png"); In the context of QML you need to address these components via URL. Therefore, Qt allows you to use the "qrc" URL schema: //C++ example:
QUrl url("qrc://resource/content.data"); Up to now neither ":/" files nor "qrc:/" URLs can be used to address classpath resources in QtJambi. |
Hi. Just saw that you responded to another issue. Is MediaPlayer in QML being fixed? |
No, you will have to wait for next QtJambi release. I already fixed the solution but did not yet publish it. Sorry. |
solved |
Describe the bug
iconfont doesn't work as expected in qml.
Expected behavior
Hi, just woke up and saw a message about the uic release. Exciting. So I opened another project but it has nothing to do with uic.
The problem is that I use FontLoader to load the iconfont icon font under the classpath in qml, and the interface shows garbled characters after the reference. Not as expected. I'm fine in Qt. What's happening here? Even writing an absolute path doesn't work as expected.
Please test it: use FontLoader to load iconfont font in Qml, then use font in Lable [e.g: \ue685]
e.g:
use:
iconfont official website: https://www.iconfont.cn/ You need to log in with your GitHub account, and then select the font to download.
Screenshots
If applicable, add screenshots to help explain your problem.
System (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: