【问题标题】:Is there an 'Editing Finished" signal for a QListWidget?QListWidget 是否有“编辑完成”信号?
【发布时间】:2013-05-24 22:47:24
【问题描述】:

我有一个QListWidget 控件,我有一个用于selectionChanged 信号的插槽。该列表配置为多选。当用户拖动以选择多个项目时,当鼠标按钮仍然按下时,插槽被调用。在释放鼠标按钮之前,我不想处理更改。我真正需要的是某种 Editing Finished 信号,尽管不一定需要失去对控制的关注。请给这位新手一些指导好吗?

【问题讨论】:

    标签: qt signals qlistwidget


    【解决方案1】:

    http://doc.qt.io/qt-4.8/qlistwidget.html#signals

    http://doc.qt.io/qt-4.8/qfocusevent.html

    http://doc.qt.io/qt-4.8/qmouseevent.html

    http://doc.qt.io/qt-4.8/qtimerevent.html

    使用上述事件的某种组合,或者您的QListWidget 中已经内置的信号,开始“完成编辑计时器”。当再次单击或编辑时,重置计时器。在计时器超时时,进行计算或过滤。

    例如:

    subclass QListWidget.
    
    initialize the timer (singleshot, set at 750 ms or so)
    
    itemSelectionChanged => start the timer
    
    mousePressEvent => stop the timer
    
    mouseReleaseEvent => start the timer
    
    keyPressEvent => (shift),(ctrl), or (arrows) => stop the timer
    keyReleaseEvent => (all keys released) => start the timer
    
    focusOutEvent => start the timer
    
    focusInEvent => stop the timer
    
    connect the timer's timeout signal to a custom signal `myEditingFinished`
    

    在您的QListWidget 之外,将其myEditingFinished 信号连接到runDatabaseQuery 或任何您想做的事情。

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多