Results 1 to 4 of 4

Thread: Text orientation in header from QStandardItemModel

  1. #1
    Join Date
    Jul 2009
    Location
    Switzerland
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Text orientation in header from QStandardItemModel

    Is it possible to turn a text in a header from a QStandardItemModel? I can't find a soloution.

  2. #2
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    1
    Qt products
    Platforms
    MacOS X Unix/X11 Windows

    Question Re: Text orientation in header from QStandardItemModel

    I've got the same issue, and can't find a solution.

    If anyone have any suggestion..

    My latest test, I've subclassed http://doc.qt.io/qt-4.8/qheaderview.html define http://doc.qt.io/qt-4.8/qheaderview.html#paintSection as this:
    Qt Code:
    1. class VerticalTextHeaderView(QtGui.QHeaderView):
    2. def __init__(self, *args, **kwargs):
    3. QtGui.QHeaderView.__init__(self, *args, **kwargs)
    4.  
    5. def paintSection(self, painter, rect, logicalIndex):
    6. painter.rotate(-90)
    7. return QtGui.QHeaderView.paintSection(self, painter, rect, logicalIndex)
    To copy to clipboard, switch view to plain text mode 

    But the results are not really appropriate...
    Not really sure about what to do.

  3. #3
    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: Text orientation in header from QStandardItemModel

    Well, since a model doesn't have a header the original (year-old) question makes little sense.

    Your approach with replacing the header view painting is good but you may also need to translate the drawing to keep it visible, and adjust the size of the sections (reimp. sectionSizeFromContents()) for the narrower width/taller height.

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

    Djab (2nd October 2012)

  5. #4
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    1
    Qt products
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Text orientation in header from QStandardItemModel

    Thanks Chris for your answer !
    I thought, I needed to do something for the dimensions... but i didn't know how, thanks !

    I'm not sure to understand what you mean here:
    you [...] need to translate the drawing to keep it visible
    Could you be more precise ?

Similar Threads

  1. QListWidgetItem's icon and text orientation
    By circass in forum Qt Programming
    Replies: 5
    Last Post: 17th June 2010, 09:03
  2. QTabBar Text and Icon orientation
    By Gravis in forum Qt Programming
    Replies: 0
    Last Post: 16th December 2009, 09:55
  3. QLineEdit text orientation
    By emrares in forum Qt Programming
    Replies: 7
    Last Post: 15th September 2009, 07:25
  4. Replies: 3
    Last Post: 1st February 2008, 19:18
  5. Vertical Orientation of Text.
    By ashukla in forum Qt Programming
    Replies: 9
    Last Post: 28th January 2008, 13:40

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.