Qt/C ++:何时检查QListWidgetItem的信号? [英] Qt/C++: Signal for when a QListWidgetItem is checked?

查看:167
本文介绍了Qt/C ++:何时检查QListWidgetItem的信号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表单中,我有一个 QListWidget ,其中包含可检查的 QListWidgetItems .我正在寻找一种捕获 QListWidgetItem 事件的方法,该事件已被选中/未选中.我看不到任何此类信号,但也许我错了.我现在正在做的是使用 QListWidget :: itemClicked()信号并检查 QListWidgetItem checkState ,但这不是我想要的是因为此事件在单击该项目的任何时间发生,而不仅是选中标记被切换.有人可以帮忙吗?谢谢!

In my form I have a QListWidget which contains checkable QListWidgetItems. I'm looking for a way to capture the event of a QListWidgetItem being checked/unchecked. I don't see any such signal existing for this but maybe I'm wrong. What I'm currently doing is using the QListWidget::itemClicked() signal and checking the checkState of the QListWidgetItem, but this isn't what I want because this event happens any time the item is clicked, not just went the checkmark is toggled. Can anyone give some assistance? Thanks!

推荐答案

显然没有提供此类信号,您最好的选择是使用

Apparently no such signal is provided, your best bet is to use QListWidget::itemChanged(QListWidgetItem* item) , and scan the resulting item->checkState(). This should be a slight improvement over using itemClicked

这篇关于Qt/C ++:何时检查QListWidgetItem的信号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆