resource file in PyQt4

前端 未结 1 969
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 06:21

I\'m trying to understand an example in PyQt4 (simpletreemodel.pyw) I see the code

import simpletreemodel_rc

But I can\'t see where the mod

1条回答
  •  离开以前
    2020-12-10 07:22

    What you see is the byte-by-byte dump of the resources the .qrc file contains. You don't explicitly access the objects inside the module. Just import it, and you will be able to access those resources by their original names(and paths) but preceded by a colon.

    pixmap = QPixMap(':/images/filename.jpg')
    

    UPDATE: QRC file is an XML file that looks like below:

    
      
        images/filename.jpg
      
    
    

    Then to generate it, use:

    pyrcc4 -o images_rc.py images.qrc
    

    0 讨论(0)
提交回复
热议问题