Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22

Thread: Calendar with QTableWidget and QItemDelegate

  1. #21
    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: Calendar with QTableWidget and QItemDelegate

    And a second question:
    What is better for performance: handling the whole table design (background color, text etc.) directly via QItemDelegate:aint(...) or would it be better to create QTableWidgetItems and set the specific background colors? I mean, setting background colors via delegate would result in updating the background color each time anything happens, but that is not neccessary for me, because I set the background colors once and they are static. On the other hand, I could imagine that the delegate will do that anyway, because, as I know now, it gets the information from the table so it will repaint the backgrounds like the QTableWidgetItems orders it...

    So, is there any sense in using QTableWidgetItems when I use a custom delegate anyway?
    It sounds to me that what you really need is to pop up a level in the widget hierarchy and use a QTableView (instead of QTableWidget) and derive a model from QAbstractTableModel. In the model's data() method, you have control over all kinds of appearance things. See Qt::ItemDataRole. In trying to implement a delegate that jumps through all these hoops, you are essentially reinventing all of the functionality that QAbstractTableModel / QTableView give you for free.

  2. #22
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Calendar with QTableWidget and QItemDelegate

    Quote Originally Posted by Binary91 View Post
    n my case, I let all data draw directly via QPainter, so the data is never stored into the table. One could say, the table doesn't know, that any data exists.
    You are saying that your delegate uses the row and column information to get the data from a separate data structure?

    Quote Originally Posted by Binary91 View Post
    How can I address this data and how can I react on user interaction with this data? I mean, I'd like to have clickable links drawn with QPainter::drawText(..), but I don't know where to ask for information when the whole view doesn't know anything about the data... How can I do that?
    Well, if you get your data from some custom data structure, then why can you access it in paint() but not when handling user event?

    Quote Originally Posted by Binary91 View Post
    What is better for performance: handling the whole table design (background color, text etc.) directly via QItemDelegate:aint(...) or would it be better to create QTableWidgetItems and set the specific background colors? I mean, setting background colors via delegate would result in updating the background color each time anything happens, but that is not neccessary for me, because I set the background colors once and they are static. On the other hand, I could imagine that the delegate will do that anyway, because, as I know now, it gets the information from the table so it will repaint the backgrounds like the QTableWidgetItems orders it...
    Well, the painting is always done by the delegate.
    Whether you use the background brush provided by via the options or decide on color based on some data in the delegate shouldn't make much difference.

    Quote Originally Posted by Binary91 View Post
    So, is there any sense in using QTableWidgetItems when I use a custom delegate anyway?
    As I said before, those handle different levels.
    The widget item is used as an API for adding data to the table.
    The delegate is painting that data.

    Whether you want to handle the data via widget items or via a model is orthogonal to using a delegate to achieve a custom visualization.

    Cheers,
    _

Similar Threads

  1. Syncing Android Calendar with our own calendar?
    By Awareness in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 16th February 2014, 19:17
  2. Replies: 4
    Last Post: 9th October 2013, 15:27
  3. calendar
    By santhosh in forum Newbie
    Replies: 10
    Last Post: 17th March 2011, 10:02
  4. QTablewidget and QItemDelegate?
    By whitefurrows in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2010, 15:33
  5. QItemDelegate use in QTableWidget
    By arpspatel in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2009, 22:18

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.