PDA

View Full Version : Multiline QPushButton



uestebanez
7th October 2008, 09:00
Hi,
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.

JimDaniel
7th October 2008, 19: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.

aamer4yu
7th October 2008, 20: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.

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

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