开发者

Qt::How to lower the text in a QSpinBox

I'm using a spinbo开发者_如何学Pythonx 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.


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:

spinbox->setStyleSheet("QSpinBox { bottom: -2px;}");

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:

spinBox->setAlignment(Qt::AlignCenter);//Or the Align Flag that you want

I hope this help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜