Results 1 to 18 of 18

Thread: QListView ~ Center items horizontally

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #17
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListView ~ Center items horizontally

    Line 18 has no effect, since the item is as wide as its parent.

    Line 24 is no anchor and, as previously explained, has no effect since the Text element has just enough width to hold the text.
    Basically the same result as line 18.

    In order to center something inside something else, the first needs to be smaller than the latter, or the latter needs to be bigger.

    So what you have is
    - a Text element that is just wide enough to display the text
    - a Column element that is just as wide and positioned at 0/0 (default position)

    What you want is
    - a Column element that is larger than the Text, probably as wide as its parent
    - either a Text element horizontally anchored in it or a Text element with the same width and using alignment

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    scgrant327 (15th March 2016)

Similar Threads

  1. Replies: 7
    Last Post: 9th September 2013, 08:31
  2. Center icon in QListView using QStyledItemDelegate
    By franki in forum Qt Programming
    Replies: 1
    Last Post: 11th June 2013, 08:53
  3. How to align list items to the center?
    By zgulser in forum Qt Tools
    Replies: 4
    Last Post: 9th February 2009, 09:52
  4. Center TabBar horizontally on the TabWidget
    By forrestfsu in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2007, 14:26
  5. Q3listbox center items
    By sreedhar in forum Qt Programming
    Replies: 3
    Last Post: 24th February 2006, 11:21

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
  •  
Qt is a trademark of The Qt Company.