Results 1 to 11 of 11

Thread: [QPushButton] text below icon

  1. #1
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default [QPushButton] text below icon

    Hello!

    Is there any simple way to put text below icon on button? I've tried, but text is always on right. I know that there is Qt::LayoutDirection, but there is only from right to left or from left to right.

    thanks in advance
    best regards
    Tomasz

  2. #2
    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: [QPushButton] text below icon

    Use QToolButton instead of QPushButton and take a look at the properties it offers.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Tomasz (3rd December 2010)

  4. #3
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: [QPushButton] text below icon

    Can I use only Qt::ToolButtonStyle? I'm asking because Qt::ToolButtonTextUnderIcon sets icon on top of the button (icon small and the button is big). Can I put it in the middle of a button?

    thanks in advance
    best regards
    Tomasz

  5. #4
    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: [QPushButton] text below icon

    Put what in the middle of the button?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: [QPushButton] text below icon

    Icon. It's aligned to the top. I've tried to set it by stylesheet but with no result.

    thanks in advance
    best regards
    Tomasz

  7. #6
    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: [QPushButton] text below icon

    You can't put it in the middle because there is a text there... I don't think I understand your problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: [QPushButton] text below icon

    Quote Originally Posted by wysota View Post
    You can't put it in the middle because there is a text there... I don't think I understand your problem.
    Mayby I didn't put it clear. Sorry! So, I want text to be bottom-aligned and icon above it (in the middle of empty space of my button). Now I've got top-aligned icon, and text somewhere in the middle of empty space below icon.

    thanks in advance
    best regards
    Tomasz

  9. #8
    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: [QPushButton] text below icon

    Did you adjust the iconSize property to the size of your icon?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: [QPushButton] text below icon

    hi, Tomasz,
    u can resise ur icon , so tat ur text will be on the base. if u hav a small icon , the text will be in centre. when u increase the icon's size ur text will be positioned in the bottom.

    hope it helps
    Bala

  11. #10
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: [QPushButton] text below icon

    My button size is 150x100. Icon size is 50x50, and I've also set iconSize to 50x50 (don't want bigger). Maybe it's a little bit weird to make button that size but i would like it this way.

    thanks in advance
    best regards
    Tomasz

  12. #11
    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: [QPushButton] text below icon

    In that case it might be quicker to reimplement the paint event for the button and draw it yourself. Optionally you can place the icon on a larger pixmap so that the icon seems to be larger to fool QToolButton's layouting scheme.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How stretch icon in QPushButton?
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 8th July 2010, 08:54
  2. QPushButton - Only show the Icon
    By graciano in forum Newbie
    Replies: 9
    Last Post: 19th September 2009, 21:15
  3. QPushButton Icon Image
    By QbelcorT in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2009, 14:26
  4. QPushButton, Icon right of text [solved]
    By Mike in forum Qt Programming
    Replies: 5
    Last Post: 31st January 2008, 20:53
  5. Stretching Icon in QPushButton
    By dsandber in forum Qt Tools
    Replies: 1
    Last Post: 6th October 2007, 16:51

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.