QT setCurrentIndex不会发出用于无效的模型Inderex的CurrentChange
Qt setCurrentIndex does not emit currentChanged for invalid ModelIndex
我有一个向导,只有在用户从qlistview选择条目时,只允许用户进步。为了检查这一点,我已将包含验证逻辑的方法连接到currentChanged
信号,但是如果所选索引无效,则不会发出信号:
// It's connected like this
connect(connectionsListView->selectionModel(),
SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(connectionSelected(QModelIndex)));
// Does not emit for empty ListModel
connectionsListView->selectionModel()->setCurrentIndex
(connectionListModel->index(0, 0), QItemSelectionModel::SelectCurrent);
// Does not emit whatsoever
connectionsListView->selectionModel()->clear();
// Valid selections are delegated to my validation logic and handled correctly
有什么想法为什么会发生这种情况以及我能做什么来解决这个问题?目前,我有第二个信号,即我在索引无效的情况下在代码中发射的,但是如果索引无效,我希望QT简单地发射信号。
第一行无法散发,因为索引没有改变:这是无效的,并且由于模型为空,但仍然无效。有一个不变的:在空模型上,选择索引无效。因此,只要模型为空,就永远不要期望currentChanged
信号发射。
第二行不会出于相同的原因发射:索引仍然无效。
您可能需要创建一个复制问题的测试用例:您需要执行更改currentIndex
返回的值但不会发射信号的值。请注意,重置选择模型不会发射信号。您可以将其视为错误。
相关文章:
- Openssl 1.1.1d无效使用不完整的类型"struct dsa_st"
- 无法访问嵌套类.类的使用无效
- QTableView:endMoveRows在模型中重置水平页眉大小
- 如果用户输入无效,如何使用字符串变量-C++重复输入命令
- 将IBM Rhapsody模型集成到VS 2019中
- 旋转模型矩阵时的形状失真
- 如何解决错误:SCIP C++中的 SCIP 阶段无效 <10>
- 在没有参数列表的情况下使用模板名称"Event"无效,模板问题
- FFMPEG配置文件级别id大小无效
- 错误:从"int"到枚举c++的转换无效
- 如何修复此错误:className::className的无效使用
- 为什么将值返回函数传递给重载=运算符对运算符函数有效,而对其他运算符无效
- C++-模板嵌套类的引用初始化无效
- 错误:无效的预处理指令 #i 的意思是 #if?
- 成员函数调用和C++对象模型
- 多维数组 C++ 中数组下标的类型"int[int]"无效
- 连接 dockerized 模型和 dockerized 数据库时出现"无法 SQLConnect"错误
- 打印 ONNXRUNTIME::图形没有模型
- Tensorflow模型在Python中有效,但在C++中无效
- QT setCurrentIndex不会发出用于无效的模型Inderex的CurrentChange