Results 1 to 5 of 5

Thread: change LayoutDirection of some columns

  1. #1
    Join Date
    Apr 2010
    Posts
    17
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default change LayoutDirection of some columns

    In a QTableWidget, i need some columns to be in layoutDirections other than tables default direction.
    is it possible?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: change LayoutDirection of some columns

    Sounds like a job for a custom item delegate.

  3. #3
    Join Date
    Apr 2010
    Posts
    17
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: change LayoutDirection of some columns

    i know how to reimplement, but in which function and what object i should apply direction?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: change LayoutDirection of some columns

    I don't have any RTL text experience but it seems that QStyledItemDelegate::paint() of your custom delegate class could switch the painter layout direction before formatting/rendering the text.

  5. The following user says thank you to ChrisW67 for this useful post:

    Chromatix (31st August 2015)

  6. #5
    Join Date
    Apr 2010
    Posts
    17
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: change LayoutDirection of some columns

    thanx.
    Qt Code:
    1. void QCustomStyledItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    2. {
    3. QStyleOptionViewItem styleOption(option);
    4. styleOption.direction=Qt::LeftToRight;
    5. styleOption.displayAlignment=Qt::AlignRight;
    6.  
    7. QStyledItemDelegate::paint(painter,styleOption,index);
    8. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to rosenth for this useful post:

    Chromatix (31st August 2015)

Similar Threads

  1. Replies: 0
    Last Post: 5th August 2010, 12:29
  2. How to change columns order in a QTableView...
    By cydside in forum Qt Programming
    Replies: 1
    Last Post: 20th April 2009, 10:42
  3. Replies: 8
    Last Post: 14th August 2008, 15:48
  4. LayoutDirection autodetection
    By momesana in forum Qt Programming
    Replies: 4
    Last Post: 19th January 2008, 15:32
  5. Moving columns/hiding columns in QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2007, 16:22

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.