c++ - qt - Drag & Drop : Frame disappears -
i'm create drag , drop between 2 qgroubbox. each contains dragdropframes, subclass qframe, have problem when want release dragdropframe groupbox, disappear instantly
dragdropframe:
void mousepressevent(qmouseevent *ev) { if (ev->button() == qt::leftbutton) { offset = ev->pos(); if(!isreleasefromparentwidget) { releasefromparent(ev->pos()); } ismousedown = true; } }; void mousereleaseevent(qmouseevent *ev) { if (ev->button() == qt::leftbutton) { ismousedown = false; } } void mousemoveevent(qmouseevent *ev) { if (ismousedown) { this->move(maptoparent(ev->pos() - offset)); } } void releasefromparent(qpoint point) { oldparentwidget = parentwidget(); setparent(parentwidget()->parentwidget()); isreleasefromparentwidget = true; this->move(maptoparent(offset)); }
when call releasefromparent in constructor dragdropframe , not somewhere else, works fine. if dragdrop-action not in process, every dragdropframe should have groupbox parent. knows i'm doing wrong? studyied multiple times, , think logic correct...
actually there isnt full drag , drop functionallity know, first want fix problem movement works fine.