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. thanks
A:
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.
Kaleb Pederson
2010-02-12 01:39:37
Thanks but I need to do it by reimplementing qstyle, not by using style sheets, they take up too much flash space, this is for an embedded application
Mark
2010-02-12 01:45:35
you dont need a stylsheet file ... so why would they take up too much space ?
smerlin
2010-02-12 01:51:01
@smerlin: Presumably, the code for interpreting the style sheets (inside Qt) takes too much space, and so it was not compiled in. I'm pretty sure Qt allows that option as a flag when building it.
Caleb Huitt - cjhuitt
2010-02-12 18:28:03
Really ?, im pretty sure there were only flags to ommit certain QStyles (and no option to ommit stylesheet capability) last time i used Qt's configure
smerlin
2010-02-12 22:09:34
@smerlin: You might be correct... I'm not the one to do the Qt configuration where I work... but on the other hand, we have a license that gives us access to modify the source how we please, and I know we remove compilation/linking of large swaths of Qt's code, in order to keep the size of the libraries down.
Caleb Huitt - cjhuitt
2010-02-13 15:30:19
cjhuitt is right, there are options given to you to remove style sheets. If you use qconfig to do it it is listed amongst the other styles. Removing it saves about 500Kb from a statically compiled executable.
Mark
2010-02-14 20:35:12
cjhuitt, could you please tell me how small you have managed to make Qt? the size of a statically compiled exe for example? I was just considering attempting to go through more in depth in an attempt to make it smaller, at the moment smallest I can do is 3.9Mb.
Mark
2010-02-17 21:43:49
+1
A:
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.
Caleb Huitt - cjhuitt
2010-02-12 18:31:35
thanks, unfortunately that is the area of both the text and the background, still can't find anything that isolates the text.
Mark
2010-02-14 21:38:11