Results 1 to 6 of 6

Thread: adding image and text both to a push button

  1. #1
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default adding image and text both to a push button

    Hi,

    I want to add a small image centered on the push button as well as a descriptive text below it. This should give an effect like shown in the attached image.

    button_bar.jpg

    How can I achieve this.

    Thanks in advance.
    - Charvi.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: adding image and text both to a push button

    How can I achieve this.
    By calling the methods corresponding to adding an icon and a text to a button.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: adding image and text both to a push button

    Quote Originally Posted by high_flyer View Post
    By calling the methods corresponding to adding an icon and a text to a button.
    Okay. Now how to set them one below the other ? Right they appear side by side.

  4. #4
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: adding image and text both to a push button

    Use QToolButton instead of QPushButton.

  5. #5
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: adding image and text both to a push button

    Any other way of achieving this using push button itself ?

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adding image and text both to a push button

    Sure, subclass QPushButton and override the paintEvent() to do whatever you want to paint the widget. You will almost certainly find the QToolButton easier to use.

Similar Threads

  1. Replies: 1
    Last Post: 1st August 2011, 07:17
  2. Push Button with image?
    By steve.bush in forum Newbie
    Replies: 10
    Last Post: 18th March 2011, 06:48
  3. who know about making button with text and image
    By erichong81 in forum Qt Programming
    Replies: 1
    Last Post: 17th March 2010, 06:19
  4. How to change text color of push button?
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2009, 10:32
  5. problem in Displaying image on push button
    By durgarao in forum Qt Tools
    Replies: 4
    Last Post: 2nd January 2009, 10:27

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.