Qt::如何降低 QSpinBox 中的文本
我正在使用带有自定义字体的旋转框,该字体在旋转框中看起来太高了。如何将文本移低?
我已经重新实现了 QStyle 并在另一个小部件中降低了字体,但我找不到在哪里使用旋转框来执行此操作。一定有一个 QRect
某个地方,您可以在其中移动它的顶部,但我不知道并且似乎无法找到它在哪里。
I'm using a spinbox with a custom font which looks too high in the spinbox. How do I move the text lower?
I have already reimplemented QStyle
and made the font lower in another widget but I can't find where to do it with the spinbox. There must be a QRect
somewhere where you can just move the top of it but I don't know and can't seem to find where it is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Qt 指定
QStyle::SC_SpinBoxEditField
,这似乎是您要修改的内容。如果我没记错的话,几年前我在处理样式时,您应该能够获取该子控件的选项,其中包括应该在其中绘制它的矩形。修改一下可能会得到你想要的结果。如果没有,您可以从这里开始寻找答案。Qt specifies a
QStyle::SC_SpinBoxEditField
, which appears to be what you want to modify. If I recall correctly from a few years ago when I was doing stuff with styles, you should be able to hook into getting options for that subcontrol, which would include the rect within which it is supposed to be drawn. Modifying that might get the result you want. If not, it is a place to begin searching for your answer.这更多的是猜测而不是肯定的答案,但您也许可以使用样式表来做到这一点:
理想情况下会有一个子控件或仅用于文本的东西,但 样式表文档没有列出,这可能意味着上述内容会产生不良后果。
This is more of a guess than a positive answer, but you might be able to do this with stylesheets:
Ideally there would be a subcontrol or something for just the text, but the stylesheet documentation doesn't list one, which might imply the above will have undesirable consequences.
你可以这样做:
我希望这有帮助。
You can do:
I hope this help.