c++ - How to get QGridLayout item by clicked QPoint? -


i have grid of qframes in qgridlayout , popup menu actions, targeted on cell mouse right click happens. on implementation of contextmenuevent clicked qpoint using common event->pos() how access correct cell object point? or there better alternative solution path purpose?

void x::contextmenuevent(qcontextmenuevent* event) {   // qpoint target = event->pos();     // todo: m_gridlayout-> ...     // myderivedcell->setsomething(); } 

there bunch of solutions here. simplest go through widgets, calling bool qwidget::undermouse () const. favorite this:

frame_i->setcontextmenupolicy(qt::customcontextmenu); connect(frame_i, signal(customcontextmenurequested(qpoint))         , slot(oncontextmenu(qpoint)));  ...  void x::oncontextmenu(const qpoint &pos) {     qframe *w = qobject_cast < qframe * >(sender());     ... } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -