MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / editorEvent

Method editorEvent

Misc/TableDelegates.cpp:72–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72bool
73ButtonDelegate::editorEvent(
74 QEvent *event,
75 QAbstractItemModel *,
76 const QStyleOptionViewItem &option,
77 const QModelIndex &index)
78{
79 if (event->type() == QEvent::MouseButtonPress) {
80 this->pressed = true;
81 this->rowPressed = index.row();
82 } else if (event->type() == QEvent::FocusOut) {
83 this->pressed = false;
84 } else if (event->type() == QEvent::MouseButtonRelease) {
85 QMouseEvent * e = static_cast<QMouseEvent *>(event);
86 int clickX = e->x();
87 int clickY = e->y();
88
89 QRect r = option.rect; //getting the rect of the cell
90 int x, y, w, h;
91
92 this->pressed = false;
93
94 x = r.left();
95 y = r.top();
96 w = this->buttonWidth;
97 h = r.height();
98
99 if (clickX > x && clickX < x + w && clickY > y && clickY < y + h)
100 emit clicked(index);
101 }
102
103 return true;
104}
105
106QSize
107ButtonDelegate::sizeHint(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected