Results 1 to 3 of 3

Thread: shift top of QRect to make 45 degree table header cell

  1. #1
    Join Date
    Nov 2008
    Posts
    183
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default shift top of QRect to make 45 degree table header cell

    This is a common request. I also see it has no common answer. I'm using Qt 4.4 for a project and cannot update, though I doubt a newer version would help. We want to make the table header run at 45 degree angle. Yes, I have many ways to rotate it 90/-90. The problem is all of the drawing stuff seems to take a QRect which is a point + width + height. I'm trying to avoid a cheap hack which will look bad. I know that I can temporarily blank out the cell text, let the default paintSection() do its thing then draw the text rotated. What I really need to be able to do is specify a non-squared region by specifying all 4 points so I can shift the top two over half the width of the original QRect.

    Has anybody found a way to do this? There are sooo many spreadsheets out there which can do this it seems odd we don't have the capability.

    Thanks,

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: shift top of QRect to make 45 degree table header cell

    QRect is by definition rectangular and oriented with respect to the x and y axes. You're asking for a parallelogram where the top and bottom are aligned with the x axis. A rotated rectangle is still a rectangle.

    I think your only solution is to derive from QHeaderView, change the paintSection() method to do what you want, and install an instance of that as the horizontal header for your table view. My guess is that you're going to have all kinds of layout headaches because the table is going to assume the header sections are rectangular. Your last header section extends beyond the bounds of the table view, so unless you simply clip the right-hand side to lie along the y-axis you will have to somehow fool the table into thinking it is wider than it really is.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: shift top of QRect to make 45 degree table header cell

    Quote Originally Posted by d_stranz View Post
    Your last header section extends beyond the bounds of the table view, so unless you simply clip the right-hand side to lie along the y-axis you will have to somehow fool the table into thinking it is wider than it really is.
    That's not a big issue, by reimplementing resizeEvent() of the table you can control the exact positioning of the header, control the margins and all but that does not change the fact that resizing sections might become quite painful to implement.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt table cell coloring
    By cubesnyc in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2014, 06:13
  2. Replies: 4
    Last Post: 9th March 2011, 18:25
  3. QTreeView cell as table
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2009, 09:45
  4. Making Table cell as a combobox?
    By kaushal_gaurav in forum Qt Programming
    Replies: 9
    Last Post: 1st August 2008, 12:04
  5. Table cell merge/join
    By larry104 in forum Qt Programming
    Replies: 6
    Last Post: 16th June 2006, 22:35

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.