-
Notifications
You must be signed in to change notification settings - Fork 9
hannes edited this page Feb 15, 2023
·
4 revisions
All default Qt resources can be seen with this code. Note default resources can vary between apps.
example path: :/qt-project.org/styles/commonstyle/images/up-32.png
you can use this string in the config
!print all qt resources-1676464679534.jpeg
from PySide2.QtCore import QDirIterator
it = QDirIterator(":", QDirIterator.Subdirectories)
all_resource_paths = []
while it.hasNext():
value = it.next()
if value.endswith(".png"):
all_resource_paths.append(value)
import sys
from PySide2.QtWidgets import QApplication, QGridLayout, QPushButton, QStyle, QWidget
import PySide2.QtGui
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
# icons = sorted([attr for attr in dir(QStyle) if attr.startswith("SP_")])
layout = QGridLayout()
for n, name in enumerate(all_resource_paths):
btn = QPushButton()
btn.setToolTip(name)
pixmap = PySide2.QtGui.QPixmap(name)
icon = PySide2.QtGui.QIcon(pixmap)
btn.setIcon(icon)
layout.addWidget(btn, n / 25, n % 25)
self.setLayout(layout)
w = Window()
w.show()
TODO provide example
- add icon to
Qresources
- use the path-string in the icon attribute see https://www.pythonguis.com/tutorials/qresource-system/
How a separator is represented depends on the widget it is inserted into. Under most circumstances the text, submenu, and icon will be ignored for separator actions. source
Applications
Dev Docs
Other