Results 1 to 4 of 4

Thread: Find what QTableWidgetItem is causing closeEditor(...) in my QTableWidget?

  1. #1
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Find what QTableWidgetItem is causing closeEditor(...) in my QTableWidget?

    Hi

    I use Qt 5.4.0 and in my application I have a class (call it MyTable) derived from QTableWidget. Now I wonder if/how I can find out what cell/QTableWidgetItem that causes MyTable::closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint) to be called? That is, when closeEditor(...) is entered, is there a way to find out what cell has just been edited?

    Hope this could be understood.

  2. #2
    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: Find what QTableWidgetItem is causing closeEditor(...) in my QTableWidget?

    maybe describe what you want to effectively achieve. there could be other ways of doing that.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Find what QTableWidgetItem is causing closeEditor(...) in my QTableWidget?

    Hi,
    Well, basically what I need is to be able to find out what is the data (QTableWidgetItem::​data(int role)) of the item that's being edited. This is of importance for me since futher processing of the content in the cell depends on the data (in my case, role is Qt::UserRole). In some special cases, I will need to programmatically change the content of the cell, and I do not know that until I'm in MyTable::closeEditor(). At least, I cannot find a way. The QTableWidget::​cellChanged() won't do for example when I've edited the cell content but not changed it (that is, simply written the same text again as was in the cell before). I really need to know what cell has been edited (but maybe not changed) also for such cases.
    Perhaps only more confusing...

  4. #4
    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: голосовые поздравления другу

    Sounds like what you really need is your own item delegate and overwriting setEditorData() to do your checks.

    I am not sure which delegate the QTableWidget uses by default, but it is probably a QStyledItemDelegate.
    So deriving from that and reimplementing the method should come close.

    Cheers,
    _

Similar Threads

  1. Properly using QTableWidget and QTableWidgetItem
    By c0dehunter in forum Newbie
    Replies: 4
    Last Post: 27th October 2012, 15:38
  2. Replies: 1
    Last Post: 10th January 2012, 21:59
  3. QTableWidgetItem for a QTableWidget
    By Archa4 in forum Newbie
    Replies: 1
    Last Post: 28th April 2011, 11:11
  4. QTableWidget or QTableWidgetItem CSS
    By ajayajgdeva in forum Newbie
    Replies: 0
    Last Post: 5th February 2010, 13:47
  5. QTableWidget QTableWidgetItem
    By TheKedge in forum Qt Programming
    Replies: 3
    Last Post: 6th September 2006, 15:03

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.