[英]Qt QSpinBox accelerated step size
I have a QSpinBox
in Qt. 我在Qt中有一个QSpinBox
。 The widget comes with one increaseValue and one decreaseValue arrow. 该小部件带有一个crementValue和一个reducingValue箭头。 Clicking the arrow increases the value as determined by singleStep
, while pressing and holding the arrow increases the value by singleStep
every X milliseconds (depending on system settings). 单击箭头会增加由singleStep
确定的singleStep
,而按住箭头会每X毫秒增加一次singleStep
的值(取决于系统设置)。
What is the best way to implement an experience where pressing and holding will increase / decrease the value faster as times goes on. 什么是实现一种体验的最佳方法,即随着时间的推移,按住会更快地增加/减小值。 I am thinking of either 我在想
Start with singleStep
increments for the first 2 seconds, then increment by 2 * singleStep
, then 4 * singleStep
, until released 首先在前2秒内以singleStep
递增,然后以2 * singleStep
递增,然后以4 * singleStep
递增,直到释放
Increment by singleStep
every X milliseconds, then after the first 2 seconds of holding the arrow pressed, increment by singleStep
every X / 2 milliseconds, etc 每X毫秒增加一次singleStep
,然后在按住箭头键的前2秒后,每X毫秒增加一次singleStep
/ 2毫秒, singleStep
Whichever is easier. 以较容易的为准。
As a first suggestion you should try the built-in functionality of the QSpinBox
. 作为第一个建议,您应该尝试使用QSpinBox
的内置功能。
#include <QSpinBox>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
auto w=new QSpinBox;
w->setAccelerated(true);
w->show();
return a.exec();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.