Mooncalf TD 2022-10-18 17:04 采纳率: 100%
浏览 27
已结题

如何在TreewidgetItem内添加QT的控件

如何使用python QT 在TreewidgetItem内添加QT的控件,如进度条之类的
  • 写回答

3条回答 默认 最新

  • bostonAlen 2022-10-18 17:22
    关注

    以button为例,

     def add_widget(self, button, widget):
            """creates a QWidgetItem containing the widget,
            as child of the button-QWidgetItem
            """
            section = QTreeWidgetItem(button)
            section.setDisabled(True)
            self.tree.setItemWidget(section, 0, widget)
            return section
    

    从原函数上看,继承于widget的组件应该都可以。

    void setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget);
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 11月11日
  • 已采纳回答 11月3日
  • 创建了问题 10月18日