我有一个QPushButton
,其中我已连接到pressed()
信号,并设置了autoRepeat=true
。QT中的QPushButton上的“点按并按住”触摸事件的问题
该按钮用鼠标单击时更新一个数字,并且当您单击并按住它时重复该按钮。
这适用于鼠标。单击一次,单击并保持重复。简单的水龙头可以使用触摸屏正常工作,但不会在“点按并按住”时重复。
我曾尝试禁用Windows 8中的“点击并按住右键单击”设置,但这并没有帮助。它只能防止右击发生。
如果我点击QPushButton并将手指从按钮上移开(同时仍然按住),然后将手指移回QPushButton工作区,pressed()事件将启动autoRepeating。
MyPanel.ui:
<widget class="QPushButton" name="UpButton">
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
</widget>
<connection>
<sender>UpButton</sender>
<signal>pressed()</signal>
<receiver>my_panel</receiver>
<slot>UpAction()</slot>
<hints>
<hint type="sourcelabel">
<x>40</x>
<y>261</y>
</hint>
<hint type="destinationlabel">
<x>121</x>
<y>37</y>
</hint>
</hints>
</connection>
MyPanel.cpp:
void MyPanel::UpAction()
{
myNumber += 1;
}
您是否尝试过使用'Qt :: TapAndHoldGesture'? – nnb 2014-10-17 12:20:50