Results 1 to 5 of 5

Thread: Multiline QPushButton

  1. #1
    Join Date
    Oct 2008
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Multiline QPushButton

    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.

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Multiline QPushButton

    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.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Multiline QPushButton

    Am not sure how much space u are getting, and how much space u need.
    You can try QFont::setFixedPitchor 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.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Multiline QPushButton

    Or you can use QxtPushButton.
    J-P Nurmi

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Multiline QPushButton


Similar Threads

  1. Adding Image to QPushButton
    By Seema Rao in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2011, 09:06
  2. QPushButton not calling repaint when needed?
    By Enygma in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2010, 17:03
  3. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 07:14
  4. Replies: 3
    Last Post: 26th September 2006, 12:16
  5. QT4 layout of complex dialog is very slow
    By cboles in forum Qt Programming
    Replies: 15
    Last Post: 28th April 2006, 19:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.