1

I have been trying to figure out why this happens but in vain. I have a QTableView that has different delegates (QStyledItemDelegate inherited classes) for each column. I tested the delegates in another view and they work fine.

My problem is that when i click a cell in the QTableView, it selects the cell and starts editing but immediately after that it loses focus causing the editor to close.

I could have included code but it's rather a lot, so i choose not to because i dont think it will be helpful.

My question is, how can i detect what makes my QTableView lose focus when i click on a cell?

Any help is appreciated.

fonZ
  • 2,428
  • 4
  • 21
  • 40
  • 2
    Maybe it helps http://qt-project.org/doc/qt-5/qfocusevent.html#reason – Jablonski Nov 19 '14 at 18:51
  • Is the table holding static data or is it possibly receiving new data while you're editting? – tinkertime Nov 19 '14 at 18:52
  • @yankee2905 it's dynamic but data comes in on user interaction. So it's not possible that the data changes while the user is pointing his mouse in the table. – fonZ Nov 19 '14 at 18:54
  • @Chernobyl the reason function gave me Qt::OtherFocusReason :( – fonZ Nov 19 '14 at 19:06
  • 1
    Try to create a breakpoint on a focus event debug output line and examine backtrace. – Pavel Strakhov Nov 20 '14 at 02:31
  • @Pavel Strakhov Yea the backtrace ends up in assembler because it's calling some magic Qt stuff, so it's hard to read and leaves me clueless. Something happens in the QApplication event loop i guess but that is all i can think of. – fonZ Nov 20 '14 at 20:37

0 Answers0