qrc 파일이라고, 프로젝트에 쓰이는 아이콘 파일들의 정보를 저장하는 파일이 있다.
형태는 대략 아래와 같다. (실제 파일은 프로젝트 폴더 밑에 icons 폴더 아래에 두면 되겠죠? :) )
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icons/play.png</file>
<file>icons/pause.png</file>
<file>icons/stop.png</file>
</qresource>
</RCC>
이를 python code에서 불러 쓰기 위해 uic 로 ui 파일 변환해서 쓰듯이
rcc 로 리소스 파일을 py code 로 변환해서 사용해야 한다.
(pyside2를 사용하고 있으므로 rcc 명령이름은 pyside2-rcc 네요.)
pyside2-rcc icons.qrc -o rc_icons.py
그리고 사용할 파이썬 코드 위에 import 해서 사용하면 된다.
import rc_icons
stopIcon = QIcon(QPixmap(":/icons/stop.png"))
레퍼런스는 여기
doc.qt.io/qtforpython/tutorials/basictutorial/qrcfiles.html
Using .qrc Files (pyside6-rcc) — Qt for Python
Using .qrc Files (pyside6-rcc) The Qt Resource System is a mechanism for storing binary files in an application. The most common uses are for custom images, icons, fonts, among others. In this tutorial you will learn how to load custom images as button ico
doc.qt.io
BJ.

'IT > 파이썬' 카테고리의 다른 글
파이썬 윈도우 크기와 포지션 정보 가져오기 및 세팅하기 (0) | 2021.02.02 |
---|---|
파이썬 Qt Designer 에서 Layout stretch 옵션 값 설정 (0) | 2021.02.01 |
파이썬 Qt Designer 로 원 모양 진행바 만들어보기 (0) | 2021.01.27 |
파이썬 flask mongodb document count 리턴해주기 (0) | 2021.01.26 |
파이썬 flask post 받은 데이터 REST API 로 재 호출하기 (0) | 2021.01.25 |