Results 1 to 3 of 3

Thread: How to right-justify the text inside a QComboBox

  1. #1
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question How to right-justify the text inside a QComboBox

    I have a QComboBox with different texts. I want to display only the most right characters of the texts since each text represent a long file name.

    How to right justify my texts in the QComboBox?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to right-justify the text inside a QComboBox

    You could try using the QComboBox::setItemData() method with the Qt::TextAlignmentRole and a value of Qt::AlignRight | Qt::AlignVCenter. I do not know if the combo box will obey this, but it is worth a try.

    You could also create a left-elided string using QFontMetrics::elidedText() if you know the width of the text field in the combo box.

  3. #3
    Join Date
    Dec 2013
    Location
    Colorado
    Posts
    45
    Thanks
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: How to right-justify the text inside a QComboBox


Similar Threads

  1. How to right-justify text line inside a QTreeView
    By mut in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2014, 03:23
  2. Replies: 2
    Last Post: 13th August 2012, 09:23
  3. breakpoint inside QComboBox subclass not working
    By yodasoda in forum Qt Programming
    Replies: 6
    Last Post: 4th June 2010, 17:02
  4. How to right-justify QLabel text
    By JimDaniel in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2008, 08:55
  5. QComboBox inside QTableWidget
    By campana in forum Qt Programming
    Replies: 7
    Last Post: 20th March 2006, 17:22

Tags for this Thread

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.