Results 1 to 5 of 5

Thread: Questions about Subclassing QItemDelegate

  1. #1
    Join Date
    Sep 2009
    Posts
    64

    Default Questions about Subclassing QItemDelegate

    So, I have a question about creating a subclass of the QItemDelegate... often named "MyItemDelegate"

    I am trying to create a border around certain rows of my QTableWidget, would this be possible by subclassing the QItemDelegate? If yes, then how exactly would i do that?

    Everything i have looked up about the QItemDelegate hints that subclassing it would only allow me to customize individual items in the table, and not the whole row. But then again, im no Qt expert and im still learning.

    Please, any help would be greatly appreciated. Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Questions about Subclassing QItemDelegate

    I am not sure how we could help you. You have to subclass QItemDelegate. There is nothing to help so far. For customising you have to alter the paint method.

    To see how a (more complex) subclassing works have a look at the Spin Box Delegate Example in the docs. If you than have more specific question we could help you.

  3. #3
    Join Date
    Sep 2009
    Posts
    64

    Default Re: Questions about Subclassing QItemDelegate

    thanks ill look into the documentation.

    ill try to be more specific with my question. I am trying to create a border around the rows of my QTableWidget. At the moment i dont see any way of doing that, i only see a way to create a border around the whole QTableWidget. I am just trying to create one around the rows individually... is this specific enough?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Questions about Subclassing QItemDelegate

    See QTableView::setShowGrid() and QTableView::setGridStyle(). If that is not enough for you subclass the paint method and do the painting yourself. (See the documentation to QItemDelegate::paint() there is also an example...)

  5. #5
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Questions about Subclassing QItemDelegate

    One way could be:

    - not showing the table grid,
    - calculate the total length of a row,
    - draw a rectangle using this length value, for each row .

    As Lykurg stated, you have to subclass the QItemDelegate:aint() method to do that.

    It's basically a matter of getting the correct coordinates for the drawing of you rectangle.

Similar Threads

  1. QItemDelegate
    By Alex_123 in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2008, 11:40
  2. Using most of QItemDelegate
    By joshuajcarson in forum Qt Programming
    Replies: 4
    Last Post: 6th October 2008, 16:02
  3. QItemDelegate
    By cyberboy in forum Qt Programming
    Replies: 10
    Last Post: 27th June 2008, 17:41
  4. QItemDelegate signals
    By Micawber in forum Qt Programming
    Replies: 6
    Last Post: 22nd May 2008, 20:29
  5. Completer on QItemDelegate
    By gemidjy in forum Qt Programming
    Replies: 6
    Last Post: 31st March 2008, 10:29

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.