Results 1 to 6 of 6

Thread: QPushButton, Icon right of text [solved]

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    52
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPushButton, Icon right of text [solved]

    Hi,

    this is not a question, but something I want to share. I was looking for a way to place an icon right of the button text. This is useful for navigating datasets (first, prev, next, last).



    The easy way to do it, is to use QWidget::setLayoutDirection. So for the three buttons on the right you just need to do:

    Qt Code:
    1. ...
    2. pushButtonNext->setLayoutDirection(Qt::RightToLeft);
    3. pushButtonLast->setLayoutDirection(Qt::RightToLeft);
    4. pushButtonNextIssue->setLayoutDirection(Qt::RightToLeft);
    5. ...
    To copy to clipboard, switch view to plain text mode 

    Have fun!

  2. #2
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QPushButton, Icon right of text [solved]

    Yes! Qt has Layout facility and you can also set the Layout direction of Qt Application using with void setLayoutDirection ( Qt::LayoutDirection direction) http://doc.trolltech.com/4.3/qapplic...Direction-prop
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  3. #3
    Join Date
    Jan 2006
    Posts
    369
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton, Icon right of text [solved]

    Please change the text of "Next" to "Next..." and tell me what happens

    Misusing the layout direction is a bad idea.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    52
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton, Icon right of text [solved]

    ... well it may doesn't fit all purposes, but it does fit for me.
    I didn't find any other solution or sample so far. So if you know the "right" way doing it, please share ...

    Thanks.

  5. #5
    Join Date
    Jan 2006
    Posts
    369
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton, Icon right of text [solved]

    I am sorry, I don't know the exact answer. But for future reference:

    What are you doing, will result in text been showed as "...Right", even tough the "..." are typed after the word. This is because the text direction is changed as well, and for english it should always be LeftToRight and not RightToLeft.

    For more information about this, please read this wikipedia page:
    http://en.wikipedia.org/wiki/Bi-directional_text

    (which kinda licks balls, since I was expecting it to show some examples of BiDi rendering)

  6. #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, Icon right of text [solved]

    Quote Originally Posted by elcuco View Post
    Please change the text of "Next" to "Next..." and tell me what happens

    Misusing the layout direction is a bad idea.
    You can always use "...Next" in such case.

    Quote Originally Posted by Mike View Post
    ... well it may doesn't fit all purposes, but it does fit for me.
    I didn't find any other solution or sample so far. So if you know the "right" way doing it, please share ...
    I think the right way would be to implement a custom widget or send a suggestion report to TT

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Stretching Icon in QPushButton
    By dsandber in forum Qt Tools
    Replies: 1
    Last Post: 6th October 2007, 16:51
  3. QPushButton and HTML text
    By ivan.cukic in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2007, 13:48
  4. QPushbutton to fit it's text
    By Equilibrium in forum Qt Programming
    Replies: 4
    Last Post: 22nd June 2006, 16:15
  5. Icon Text Alignment
    By nupul in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 04:47

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.