qtcombobox选中触发 事件
时间: 2023-09-30 12:08:53 浏览: 380
在Qt中,可以通过重写QComboBox的mousePressEvent方法来实现在选中时触发事件。首先,需要新建一个类,比如MyComboBox,继承QComboBox类。在MyComboBox类中重写mousePressEvent方法,并在该方法中判断鼠标按钮是否是左键,如果是,则触发自定义的clicked信号。最后,调用父类的mousePressEvent方法,确保父类也能处理原本的点击事件。这样,在使用MyComboBox时,当选中该ComboBox中的选项时,就会触发clicked信号。 [2 [3<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [【QT】制作MyComboBox点击事件](https://blog.csdn.net/Roger_717/article/details/125553448)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *2* *3* [QT comboBox鼠标点击事件](https://blog.csdn.net/euxnijuoh/article/details/126508076)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文