Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QAction icon is not showing in Qtoolbar



  • I have a problem with QToolbar and QAction. I'm trying to show an action with a icon but the icon is not showing.

    This is my qrc and code example (I'm using PySide2):

    <!DOCTYPE RCC><RCC version="1.0">
    <qresource prefix="/iconos">
        <file alias="vista-inicial.svg">iconos/cubo.svg</file>
        <file alias="cubo.png">iconos/3d.png</file>
    </qresource>
    </RCC>
    
        toolbar = QtWidgets.QToolBar()
        toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        toolbar.setIconSize(QtCore.QSize(24, 24))
    
        accion_vista_inicial = QtWidgets.QAction(QtGui.QIcon(":/iconos/cubo.png"), "Vista Inicial", self)
    
        toolbar.addAction(accion_vista_inicial)
    

    And finally a little screenshot:
    alt text



  • Does this icon show in a normal QToolButton?


  • Lifetime Qt Champion

    Hi,

    Might be a silly question but did you call pyside2-rcc to generate the python code for embedding your rcc stuff ?


Log in to reply