how to set an icon on a Main window and action with QT

前端 未结 3 1208
滥情空心
滥情空心 2020-12-17 16:20

Honestly I do not understand resource files and how to get so that my things can get done, because it was partially explained to me and I\'m quite confused where to put icon

3条回答
  •  甜味超标
    2020-12-17 17:08

    Wouldn't it be the simplest to use QtCreator's Designer window? In the lower right corner you can find 3 tabs - click on the most righthand one, then click on the pen:

    qt designer resources

    This will open Resources editor:

    Qt creator Resources Editor

    Define new resources file (below the left pane), than add a "namespace" (rigth pane) and add your files. You can set aliases for them, so that when you decide to replace your icon with somethin else - you only have to switch the path, as long as alias is kept the same. You can then reference your resources via their alias to set your icon where needed, eg: setWindowIcon(QIcon(":/HurBudClientGUI/plug"));

    Also - take your time to read this: http://doc.qt.io/qt-5/resources.html and that: http://doc.qt.io/qt-5/designer-resources.html

    Good luck!

提交回复
热议问题