Results 1 to 2 of 2

Thread: absolutely center text alignment in qtablewidgetitem that has an icon

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    14
    Thanks
    4

    Default absolutely center text alignment in qtablewidgetitem that has an icon

    I have a QTableWidget which contains cells which may or may not contain QIcons in them. When I align the texts of cells with icons in them, they are centered more right than cells without icons in them.

    offset icon text alignment.jpg

    How do I make the text in cells with icons center so that they align with the entire cell, and not the text portion of the QTableWidgetItem?

    I tried:

    Qt Code:
    1. QTableWidgetItem::setTextAlignment(Qt::AlignAbsolute | Qt:: AlignCenter)
    To copy to clipboard, switch view to plain text mode 


    I have read into similar threads describing the use of QItemDelegates when considering icon alignment, but does this method work for QTableWidgetItems via medelling with the Qt:isplayRole portion of QItemDelegate or am I completely off?
    Last edited by positive_4_life; 4th April 2011 at 19:14.

Similar Threads

  1. Replies: 1
    Last Post: 21st November 2009, 20:38
  2. Icon Alignment
    By wirasto in forum Newbie
    Replies: 2
    Last Post: 18th October 2009, 17:49
  3. qstandarditem how sisplay icon in center?
    By yunpeng880 in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2009, 09:14
  4. Centering An Icon In A QTableWidgetItem?
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 14th November 2007, 23:11
  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.