View Full Version : Multiline QPushButton

7th October 2008, 10:00
I am developing an application and I need to put two lines within a button.
This can be done with "\n" character, and this works fine.

My problem is that I need to reduce the space between the two text lines in order to fit within button size (wich can't be greather because of our GUI design constraints).

Does anybody knows how can I reduce the space between the two text lines?

Thanks in advance.

7th October 2008, 20:38
I don't really know of a straightforward solution, but if none of the gurus here can help out, since QPushButton is a QWidget, you can set a layout to it, so you could create two QLabels, put them in a QVBoxLayout, set the layout to the button, and then you would have all sorts of control how they are aligned and spaced.

7th October 2008, 21:13
Am not sure how much space u are getting, and how much space u need.
You can try QFont::setFixedPitch
or u can try reducing the height of the font, or using some different font.

Last option is to inherit the button and draw the text urself. Thats all i can think of now.

12th October 2008, 20:04
Or you can use QxtPushButton (http://doc.libqxt.org/latest/classQxtPushButton.html). :)

12th October 2008, 22:25
Or QwwRichTextButton (http://www.wysota.eu.org/wwwidgets) ;)