Results 1 to 2 of 2

Thread: Label inside a button or different font sizes within a button

  1. #1
    Join Date
    Jul 2010
    Thanked 1 Time in 1 Post
    Qt products

    Default Label inside a button or different font sizes within a button

    I'm trying to create a widget for entering a password. I want a number pad to appear on screen. I was hoping to not just have numbers but also have letters displayed on the buttons exactly like the letters on the buttons of a phone.

    I thought of two ways of doing this but I don't know how to do either. The first was to make a special kind of button that is a container. I could give it a layout and add two labels in - one for the number and one for the letters. This is ideal. The second kind is a hack but I'd be happy with it too. I could just have the button text as "2\nabc" and make the "abc" part a different size font, giving it the general appearance I'm after.

    If you have a better method, let me know. I have no idea how to implement these so any suggestions would be very welcome. Thanks

  2. #2
    Join Date
    Jan 2006
    Thanked 1,005 Times in 913 Posts
    Qt products
    Unix/X11 Windows Symbian S60
    Wiki edits

    Default Re: Label inside a button or different font sizes within a button

    The easiest way would be to simple subclass QPushButton and do the painting yourself. Using QStyledPainter would also ensure that your new widget is style aware.

Similar Threads

  1. Replies: 1
    Last Post: 18th December 2009, 20:57
  2. how to track mouse button inside treeItemClickAction?
    By sudhansu in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 11:07
  3. Button grid with label rotate 90 degree
    By whitefurrows in forum Qt Programming
    Replies: 14
    Last Post: 24th June 2009, 17:17
  4. Custom widget: a button within a button
    By Gnurou in forum Qt Programming
    Replies: 7
    Last Post: 18th June 2009, 09:03
  5. Font sizes
    By StevenB in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2007, 10:10

Tags for this Thread


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.