Results 1 to 2 of 2

Thread: QComboBox text alignment

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default QComboBox text alignment

    I'd like the text inside QComboBox to be center aligned. Is that possible? I found some workaround on the web, that is a rather strange way. QSS text-align attribute seems like doesn't affect anything.

  2. #2
    Join Date
    Apr 2010
    Location
    Russian Federation, Kaluga
    Posts
    20
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox text alignment

    QComboBox doesn't support changing text's aligment for frame natively.
    For it's popup you can use setItemData(index,aligment,Qt::TextAligmentRole).
    But this way don't have effect unless you dont modify combox's view - as example you can set default QListView and see effect (see code below).
    I spend hour for QComboBox source code (4.6.3) - painting text deep inside style's code.

    But you can define you own combobox class and redefine painting =).
    But I think that this is not a good idea.

    P.S. Sorry for my english =)

Similar Threads

  1. Alignment in QComboBox
    By Naami in forum Qt Programming
    Replies: 2
    Last Post: 26th May 2010, 14:53
  2. left alignment for pushbutton text
    By BalaQT in forum Qt Programming
    Replies: 7
    Last Post: 22nd September 2009, 08:41
  3. Text Alignment in a ListWidget
    By Krish_ng in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2007, 02:19
  4. QToolButton text alignment
    By Vladimir in forum Qt Programming
    Replies: 6
    Last Post: 2nd March 2007, 07:42
  5. Icon Text Alignment
    By nupul in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 04:47

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.