Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Can't set the window icon for QML application

$
0
0
Hello, I am trying to set the window icon for the QML application window (and to get it to display in the Windows taskbar). I have tried following the instructions here [qt-project.org], but this doesn’t work. First of all, there is no setWindowIcon() method for the QtQuick2ApplicationViewer, only setIcon(). The documentation does not seem to mention this. But even if I use setIcon(), the Icon just isn’t set, so I must be missing something. I’ve searched and searched, but can’t seem to find a solution to this problem, only how to set the executable file icon (which was very helpful). main.cpp #include <QtGui/QGuiApplication> #include "qtquick2applicationviewer.h"   #include <QQmlContext>   int main(int argc, char *argv[]) {     QGuiApplication app(argc, argv);       QtQuick2ApplicationViewer viewer;     viewer.setIcon(QIcon(":/icons/images/DESIGN.ico"));     viewer.rootContext()->setContextProperty("QtQuick2ApplicationViewer", &viewer);     viewer.rootContext()->setContextProperty("extFile", &extFile);         viewer.setMainQmlFile(QStringLiteral("qml/Design2014Papers/main.qml"));     viewer.showFullScreen();     viewer.setResizeMode(QtQuick2ApplicationViewer::SizeRootObjectToView);       return app.exec(); } The icon is included as a resource. The path to the icon was acquired by right clicking on the icon in the Resource file and copying the path to the clipboard and then pasting into the QIcon constructor. Qt version 5.0.2 minGW Platform: Win7 ×64

Viewing all articles
Browse latest Browse all 13965

Trending Articles