I build a widget which accepts drag&drop as follows:
MyWidget::MyWidget( QWidget *p_parent ) : QFrame( p_parent ) { setAcceptDrops( true ); m_layout = new QLayout( this ); //this is layout of my custom widget layout->setSpacing( 0 ); m_indicator = new QWidget( this ); m_indicator->setObjectName( "indicator" ); m_indicator->setFixedWidth( 5 ); layout->addWidget( m_indicator ); .... .... } void MyWidget::dragMoveEvent( QDragMoveEvent *p_event ) { p_event->acceptProposedAction(); } My main job is to insert the dragged object into the layout, therefore, I should identify which item is under the mouse, and do my job after that. In function dragMoveEvent above, I can do p_event->pos() to get the position of the mouse. But QLayout does not have method itemAt(int x, int y). What should I do now?