[GH-ISSUE #159] How to set application icon in .net #101

Closed
opened 2026-05-05 11:04:43 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @542353921 on GitHub (Aug 19, 2019).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/159

hi,
How to set application icon like this

int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
app.setWindowIcon(QIcon(":/favicon.ico"));

QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));

return app.exec();

}

thanks

Originally created by @542353921 on GitHub (Aug 19, 2019). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/159 hi, How to set application icon like this int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); app.setWindowIcon(QIcon(":/favicon.ico")); QQmlApplicationEngine engine; engine.load(QUrl(QLatin1String("qrc:/main.qml"))); return app.exec(); } thanks
Author
Owner

@MosiQt commented on GitHub (Sep 19, 2019):

I had similar issue and solved it by writing my own plugin by overwriting QQuickWindow. I've used the plugin instead of ApplicationWindow in qml. In the plugin class, you can easily set the windowIcon.
1

After that you can set the icon path in qml:
2

<!-- gh-comment-id:533007451 --> @MosiQt commented on GitHub (Sep 19, 2019): I had similar issue and solved it by writing my own plugin by overwriting QQuickWindow. I've used the plugin instead of ApplicationWindow in qml. In the plugin class, you can easily set the windowIcon. ![1](https://user-images.githubusercontent.com/53909162/65223095-a7d2a580-dad5-11e9-8330-40fe278a31f4.png) After that you can set the icon path in qml: ![2](https://user-images.githubusercontent.com/53909162/65223188-dea8bb80-dad5-11e9-845f-2fdac0c94f27.png)
Author
Owner

@nyashabryan commented on GitHub (Jul 14, 2020):

@MosiQt do you mind going in a bit more detail about the process? Newbie here.

<!-- gh-comment-id:658268716 --> @nyashabryan commented on GitHub (Jul 14, 2020): @MosiQt do you mind going in a bit more detail about the process? Newbie here.
Author
Owner

@vadi2 commented on GitHub (May 17, 2021):

An upcoming version of QML.net will have app.SetWindowIcon(png path) method that makes this simpler.

<!-- gh-comment-id:842475710 --> @vadi2 commented on GitHub (May 17, 2021): An upcoming version of QML.net will have `app.SetWindowIcon(png path)` method that makes this simpler.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#101
No description provided.