spyder-ide / qtawesome

Iconic fonts in PyQt and PySide applications
https://qtawesome.readthedocs.io/en/latest/index.html
MIT License
808 stars 107 forks source link

Coloring icons in RGB results in very poor quality #225

Open JulianOrteil opened 1 year ago

JulianOrteil commented 1 year ago

Using the following screenshot: image

Recoloring the icons in grayscale is fine, but RGB results in the above regardless of the size. In the gray on the right of the image, the left set of icons is displayed after being converted to a QPixmap. The button on the right is keeping the icon as a QIcon. This also occurs regardless of the provider (Material Design, FontAwesome, etc).

My environment (Anaconda):

JulianOrteil commented 1 year ago

Update: setting the icon color using HEX seems to work properly...

dalthviz commented 1 year ago

Hi @JulianOrteil thank you for the feedback! Could it be possible for you to give us some basic code snippet to test this in our side? About your test using HEX, could it be something then Qt related? Also, could you try to use a different binding or version (PyQt6, PySide2 or PyQt5) to see if the error is just for PySide6? Let us know!

JulianOrteil commented 1 year ago

Apologies for the delay. I'll hopefully get an MRE to you before the end of the week. Completely overloaded right now!

StSav012 commented 1 year ago

That's the code I've got from the picture:

# -*- coding: utf-8 -*-
import sys

from qtpy import QtCore, QtGui, QtWidgets

import qtawesome as qta

class AwesomeExample(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()

        icon_name: str = 'mdi6.help-circle'
        icon_size: QtCore.QSize = QtCore.QSize(24, 24)
        icon: QtGui.QIcon = qta.icon(icon_name, color='red')

        button: QtWidgets.QToolButton = QtWidgets.QToolButton(self)
        button.setIcon(icon)
        button.setIconSize(icon_size)

        label: QtWidgets.QLabel = QtWidgets.QLabel(self)
        label.setPixmap(icon.pixmap(icon_size))

        layout: QtWidgets.QHBoxLayout = QtWidgets.QHBoxLayout()
        for w in [button, label]:
            layout.addWidget(w)
        self.setLayout(layout)

def main() -> int:
    app: QtWidgets.QApplication = QtWidgets.QApplication(sys.argv)
    window: AwesomeExample = AwesomeExample()
    window.show()
    return app.exec()

if __name__ == '__main__':
    sys.exit(main())

And it does not reproduce the issue. I have a slightly different system, though:

The last item makes me wonder whether @JulianOrteil used Wayland back then.

JulianOrteil commented 1 year ago

Thanks for the ping @StSav012. This completely fell off my radar. I was unfortunately reassigned to different projects almost immediately in the second week of January. If I can, I'll see if I can get the current team to provide any details on if they are still encountering this.

From my recollection, I was on Ubuntu 22.04 when I saw this issue. The software was being deployed on a Raspberry Pi, and through my tests, I don't recall if I ever saw this issue there.