Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Unsolved QAction icon is not showing in Qtoolbar

    General and Desktop
    3
    3
    226
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      efdiloreto last edited by

      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

      1 Reply Last reply Reply Quote 0
      • B
        Bonnie last edited by

        Does this icon show in a normal QToolButton?

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • First post
            Last post