如何在 QDateEdit 中让日子循环起来?
标准行为是,一旦当天到达 31 点,升级按钮就会停止工作。 我希望它重置为 1 并跳转到下个月。
The standard behaviour is, that as soon as the day reaches 31 the step-up button stops working. I'd like it to reset to 1 and jump to the next month.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有机会对此进行测试,但我知道 QDateEdit 实现了 QAbstractSpinBox,因此您应该能够调用
它来完成您想要的任务。
文档链接
更新:
这种行为的术语显然称为“翻转” ”这是一个人的实现,(同样,我没有测试它)似乎是另一种潜在的解决方案:
Rollover QDateEdit
他指出,他的实现不考虑最小或最大日期。
I have not had the opportunity to test this, but I know that QDateEdit implements QAbstractSpinBox, so you should be able to call
which should accomplish what you want.
Doc Link
Update:
The term for this behaviour is apparently called "rollover" and here is one person's implementation, which (again, I haven't tested it) appears to be another potential solution:
Rollover QDateEdit
He makes the point that his implementation doesn't consider min or max dates though.