获取pyqt5上Combobox项目的主题名称

发布于 2025-02-07 17:13:46 字数 1199 浏览 1 评论 0原文

我想在Qt5-Tools Designer中输入的combobox项目的QT设计师中输入主题名称:

我已经尝试了以下代码:

def load_actions_tips(self):
    combo = self.form.converter_action_choice
    for i in range(combo.count()):
        print(f"{combo.itemText(i) = }")
        print(f"{combo.itemData(i) = }")
        print(f"{combo.itemIcon(i).themeName = }")
        print(f"{combo.itemIcon(i).themeName.__name__ = }")
        print(f"{combo.itemIcon(i).themeName.__qualname__ = }")
        print(f"{combo.itemIcon(i).themeName.__repr__ = }")
        print(f"{combo.itemIcon(i).themeName.__str__ = }")
        print(f"{combo.itemIcon(i).themeName.__text_signature__ = }")
        print(f"{str(combo.itemIcon(i).themeName) = }")
        print(f"{dir(combo.itemIcon(i).themeName) = }")

目的是将主题名称自动添加到Combobox的项目值,以允许某人添加QT的ComboBox的项目的'Tooltips'如上所述的设计师在这里

这里的目标是使所选项目的变量等于“ Blablo”。

I would like to get theme name entered in QT designer of the item of a combobox entered like this into Qt5-tools designer:
enter image description here

I have try this code:

def load_actions_tips(self):
    combo = self.form.converter_action_choice
    for i in range(combo.count()):
        print(f"{combo.itemText(i) = }")
        print(f"{combo.itemData(i) = }")
        print(f"{combo.itemIcon(i).themeName = }")
        print(f"{combo.itemIcon(i).themeName.__name__ = }")
        print(f"{combo.itemIcon(i).themeName.__qualname__ = }")
        print(f"{combo.itemIcon(i).themeName.__repr__ = }")
        print(f"{combo.itemIcon(i).themeName.__str__ = }")
        print(f"{combo.itemIcon(i).themeName.__text_signature__ = }")
        print(f"{str(combo.itemIcon(i).themeName) = }")
        print(f"{dir(combo.itemIcon(i).themeName) = }")

The goal of this is to add the theme name to the item value of the combobox automatically in order to permit someone to add 'tooltips' of an item of a combobox from QT designer as described here.

The goal here is to get the variable equal to 'blablo' for the selected item.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文